Reputation: 1118
I have a div named body-container .
I want to change the width of the div depending on the browser window size. I am using the flexbox model to do it, but the width is not changing according to the size of the browser window.
My CSS :
.body-container
{
display:flex;
display:-webkit-flex;
margin-top:20px;
margin-left:20px;
margin-right:20px;
box-shadow:2px 2px 2px #A8A8A8;
width:800px;
height:250px;
}
Is there something I need to do with the margin of the divider or is there any other way to make the divider completely flexibly (width wise).
Upvotes: 0
Views: 1190
Reputation: 28
Whenever we need to have a responsive container, it is mandatory to specify width in percentage(%). Also make sure you take care of the elements within that container. Have correct break points and mention the width in percentage accordingly.
Upvotes: 0
Reputation: 371749
Instead of using width: 800px
, which uses a fixed value (pixels), use a relative value, such as percentage. Try this:
.body-container {
display:flex;
display:-webkit-flex;
margin-top:20px;
margin-left:20px;
margin-right:20px;
box-shadow:2px 2px 2px #A8A8A8;
width: 75%; /* ADJUSTED */
height:250px;
}
Upvotes: 1