Consider the basic HTML below:
<body>
Random HTML content
<div class="container">
</div>
Other random HTML content
</body>
I want the width of the "container" div to be the MAXIMUM of 3 potential values:
- 100% windows
- 1024px (for a better look)
- content width
I was able to accomplish # 1 and # 2 using CSS property widths: 100% and min-width: 1024px. I can also accomplish # 2 and # 3 by setting display: inline-block and min-width: 1024px. However, I was unable to get all three: if I add width: 100% to the display and min-width properties, it overrides the effect of the size of the content of the inline-block's display child content and gives me just 100% width, even if that means the content overflows.
I know I can hide the overflow or provide scrolling for the div div, but I want the div to expand as needed or to the full width of the window, whichever is larger - but no more than 1024px.
Edit: Please note that the content loaded in the div can be less than 1024px. However, the div itself shouldn't be smaller than that as it won't blend well with the look of the rest of the page anymore.
source
to share