I want to get a div container with default width (400px). If screen size is smaller, than that (smaller than 400px in width), then div must shrink. To do this, I'm using max-width
css property:
<div class="parent_2">
Text
</div>
.parent_2 {
max-width: 400px;
border: 1px solid gray;
}
And it works fine. However, in reality, my div is inside another third-party flex componet. So, in practice I have a code which looks like so:
.parent_1 {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.parent_2 {
max-width: 400px;
border: 1px solid gray;
}
<div class="parent_1">
<div class="parent_2">
Text
</div>
</div>
And it stops working - my own inner div shrinks just to the width of text. This is not what I want. I should add, that I'm not able to fix this third-party container and I am responsible just for this inner div. So,how can I fix it?
I want it to look just like so, but without tweeking or removing parent (class=parent_1) element:
.parent_2 {
max-width: 400px;
border: 1px solid gray;
}
<div class="parent_2">
Text
</div>