Maximum and Minimum Width Solution for All Browsers



min-width and max-width is very useful command of CSS, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page.

Unfortunately, this command IE doesn’t understand, so we’ll need to come up with a new way of making this functionality work in this browser.

First, insert a <div> under the <body> tag, as we can’t assign a minimum width to the <body>:
<body>

<div>

Next, we create our CSS commands, to create a minimum width of 600px:

#container

{

min-width: 600px;

width:expression(document.body.clientWidth < 600? “600px”: “auto”);

}

The first command is the regular minimum width command; the second is a short JavaScript command that only IE understands. Do note, though, that this command will cause your CSS document to become invalid; you may prefer to insert it into the head of each HTML document to get around this.

You might also want to combine this minimum width with a maximum width:
#container

{

min-width: 600px;

max-width: 1200px;

width:expression(document.body.clientWidth < 600? “600px” : document.body.clientWidth > 1200? “1200px” : “auto”);

}

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • DZone
  • Facebook
  • LinkedIn
  • BlinkList
  • Mixx
  • Propeller
  • Design Float
  • Furl
  • Google Bookmarks
  • Live-MSN
  • NewsVine
  • Sphinn
  • Technorati
  • TwitThis
  • YahooBuzz
  • email

Random Posts

19 Responses to “Maximum and Minimum Width Solution for All Browsers”

  1. Katie McDonnal Says:

    Great post! Nice blog.


  2. Tweets that mention Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad -- Topsy.com Says:

    [...] This post was mentioned on Twitter by Pinceladas da Web, gustavobarbosa. gustavobarbosa said: RT @pinceladasdaweb: Maximum and Minimum Width Solution for All Browsers: http://migre.me/idfX [...]


  3. You are now listed on FAQPAL Says:

    Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad…

    min-width and max-width is very useful command of CSS, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page. Unfortunately, this command IE doesn’t understand, so we’ll nee…


  4. designfloat.com Says:

    Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad…

    min-width and max-width is very useful command of CSS, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page. Unfortunately, this command IE doesn’t understand, so we’ll nee…


  5. joyoge.com Says:

    Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad…

    min-width and max-width is very useful command of CSS, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page….


  6. wparena Says:

    good one


  7. Servefault.com Says:

    Maximum and Minimum Width Solution for All Browsers

    Thank you for submitting this cool story – Trackback from Servefault.com…


  8. pligg.com Says:

    Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad…

    min-width and max-width is very useful command of CSS, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page….


  9. Vote on this article at blogengage.com Says:

    Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad…

    min-width and max-width is very useful command of CSS, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page. Unfortunately, this command IE doesn’t understand, so we’ll nee…


  10. uberVU - social comments Says:

    Social comments and analytics for this post…

    This post was mentioned on Twitter by pinceladasdaweb: Maximum and Minimum Width Solution for All Browsers: http://migre.me/idfX...


  11. favSHARE Says:

    This article has been shared on favSHARE.net. Go and vote it!


  12. Descubrimientos del 2 Febrero 2010 | Blog de unique3w Says:

    [...] Solución para máximos y mínimos tamaños de ancho para todos los navegadores. – Maximum and Minimum Width Solution for All Browsers | Ejaz Ahmad [...]


  13. Brendan Legra Says:

    Hello. I don’t read many blogs, but yours is of thefew I read.Have a awesome day!


  14. 120+ Fresh Community Posts for Designers and Developers | tripwire magazine Says:


  15. 120+ Fresh Community Posts for Designers and Developers | Afif Fattouh - Web Specialist Says:


  16. Cruz Lafrancois Says:

    I really like what you published here – it’s well-written. Thanks for posting this. I’ve been experimenting with WordPress lately. Do you utilize WordPress? Any tips for me? Click here if you’d like to check out my site. Have a great week!


  17. Drew Ridep Says:

    Hello, firstly I want to tell you that I follow your blog. Great post, I fully agree with you. Have a good day maty.


  18. pharmacy tech Says:

    nice post. thanks.


  19. CNA Salary Says:

    Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes