Reputation: 41
I am attempting to create website with a fixed width (970 px) and would like to ensure that it is adjusted to any potential user screen size, but the browser continues to display it in addition to margins created by my overall screen width.
Upvotes: 4
Views: 28437
Reputation: 7673
It's not a liquid-layout that you're after, but an 'elastic' layout, with an 'auto-stretch' script attached.
There are a few steps to getting this to work:
Apply a scaling value to your <body>
element as a percentage. This default setting is useful, because it sets 1em equal to 10px in nearly all browsers:
body {font-size:62.5%;}
This would mean your layout would have a width of 97em
.
Here's a good starting point for elastic layouts: http://www.alistapart.com/articles/elastic
Upvotes: 2
Reputation: 28188
If you are trying to make your page span 100% of the width then review this article: Liquid Layout
If you are trying to center your fixed width content on any page width simply use:
margin: 0px auto;
Upvotes: 3
Reputation: 637
If understand what you're getting at, it sounds like you set up your margins incorrectly. to center your content, you'll want your code to look something like this: http://jsbin.com/uyolo4/4/edit
Upvotes: 0
Reputation: 990
You shouldn't set the width. The contents of the page will expand to fill the entire screen by default.
If you need to find the actual width of an element, you can always find that out. If you're using jQuery, it's
var width = $("#my-element").width()
Upvotes: 1