OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

CSS Div with fixed height and automatic width

  • Thread starter Thread starter Wintersun
  • Start date Start date
W

Wintersun

Guest
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.

Code:
.container {
    background: red;
    height: 200px;
    width: auto;   
}

Here is a demo:

http://jsfiddle.net/8MqtN/2/
<p>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.</p>

<pre><code>.container {
background: red;
height: 200px;
width: auto;
}
</code></pre>

<p>Here is a demo:</p>

<p><a href="http://jsfiddle.net/8MqtN/2/" rel="nofollow">http://jsfiddle.net/8MqtN/2/</a></p>
Continue reading...
 
Top