Assign minimum width to a page

There is a CSS property min-width, with which we can specify a minimum width for an element. This can also be used to specify the minimum width for a page by assigning min-width to the oouter div of the body.

Unfortunately, IE doesn't understand this property, so we need a work around which should work in IE and other browsers.

Example:

We will create our CSS for minimum width of 800px:


#OuterDiv
{
min-width: 800px;
width:expression(document.body.clientWidth < 800? "800px": "auto" );
}

And here is our partial html code:


<html>
<body>
<div id='OuterDiv'>

<!-- contentes here -->

</div>
</body>
</html>


Description :
The first property in CSS is the regular minimum width property. The second is of JavaScript that only IE understands. As body will not take min-width property so we have inserted div to accomplish our requirement.

Note : Putting property value with javascript in the CSS file, may not be get validated. So you can put above
CSS in the head of HTML document.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: