Reputation: 1
so i want to make a div container, which i give a fixed height and want that it automatically fit its width to the content in it, even if it is over 100% of the screen width. Simply by declaring width:auto on the css of the div won't work, because it's not becoming bigger than 100% of the screen.
.container {
background: red;
height: 200px;
width: auto;
}
Here is a demo:
Upvotes: 0
Views: 10738
Reputation: 347
I just added to your css class .container
position: relative; display: table;
Now your content seems to be aware of the the height of your content. The red background you set expands accordingly to the content inside. Is that what you are trying to achieve?
Upvotes: 0
Reputation: 4550
Use the following css for your body and try once and see if you get what you want .
body
{
margin : 0;
padding: 0;
}
Upvotes: 0