Renegade605 Posted November 20, 2007 Share Posted November 20, 2007 How can I fix the width of a webpage to a certain size? If the page goes smaller than 960px wide, some text wraps, and then the whole page gets messed up. Can I make it so there's a scrollbar at the bottom instead? I do want the page to be capable being larger as well, so it won't be forced to be smaller than a user's browser window. Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted November 20, 2007 Share Posted November 20, 2007 Try adding this CSS in: html{width:960px;min-width:960px;overflow:scroll} I don't know if it will be compatible in Internet Explorer though. Link to comment Share on other sites More sharing options...
Renegade605 Posted November 20, 2007 Author Share Posted November 20, 2007 No Dice, so either it isn't compatible with IE, or it doesn't work at all.Any other suggestions? Link to comment Share on other sites More sharing options...
Synook Posted November 20, 2007 Share Posted November 20, 2007 The min- and max- prefixes don't work in IE 6 and under (though they do in IE 7). Umm... you could use JavaScript <script type="text/javascript">window.onload = function() {if (window.innerWidth) width = window.innerHeight; //For non-IEif (document.body.clientWidth) width = document.body.clientWidth; //For IEif (width < 960) document.getElementsByTagName('body')[0].style.width = 960px;}</script> Beware - you will have to set the doctype to strict for this though or else clientWidth returns the width of the window and not the actual document (i.e. + scrollbars + window border + etc). Link to comment Share on other sites More sharing options...
Renegade605 Posted November 20, 2007 Author Share Posted November 20, 2007 That didn't work either. I get a script error, saying it expects a ';' at char 76 of line 13. (Line 13 is the one with the '}') I tried adding in a semi-colon after the '}' but that didn't work, just caused another error. Link to comment Share on other sites More sharing options...
Synook Posted November 20, 2007 Share Posted November 20, 2007 Oops forgot quotation marks <script type="text/javascript">window.onload = function() {if (window.innerWidth) width = window.innerHeight; //For non-IEif (document.body.clientWidth) width = document.body.clientWidth; //For IEif (width < 960) document.getElementsByTagName('body')[0].style.width = "960px";}</script> Link to comment Share on other sites More sharing options...
Renegade605 Posted November 21, 2007 Author Share Posted November 21, 2007 lol, it works. Cheers! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.