Is this code correct for centering fixed width page?
.container {position:relative; width:900px; margine:0 auto;
text-align:left;}
Is this code correct to center fixed width page?
Page 1 of 16 Replies - 534 Views - Last Post: 25 November 2011 - 05:12 AM
#1
Is this code correct to center fixed width page?
Posted 17 November 2011 - 03:07 PM
Replies To: Is this code correct to center fixed width page?
#2
Re: Is this code correct to center fixed width page?
Posted 17 November 2011 - 03:23 PM
You've got the right idea, but there is a typo. margine should be margin.
#3
Re: Is this code correct to center fixed width page?
Posted 18 November 2011 - 04:17 AM
yes u r right
thanks
thanks
#4
Re: Is this code correct to center fixed width page?
Posted 19 November 2011 - 08:25 PM
This is my method:
For me, that's the quickest way for making a fixed-width container centered on the page.
#main {
width: 700px;
margin: 25px auto 25px auto;
padding: 15px;
border: 1px solid #848484;
}
For me, that's the quickest way for making a fixed-width container centered on the page.
#5
Re: Is this code correct to center fixed width page?
Posted 20 November 2011 - 12:06 AM
You might be careful of IE, it has a tendency not to center a page unless a text-align: center; is present. This also means making a left align in every other sub element or another container, but that's unfortunately how IE works.
@jw - Why not 25px auto instead of using all 4? Specifying 2 is the same as top/bottom left/right, 1 is all.
@jw - Why not 25px auto instead of using all 4? Specifying 2 is the same as top/bottom left/right, 1 is all.
#6
Re: Is this code correct to center fixed width page?
Posted 24 November 2011 - 11:49 AM
#7
Re: Is this code correct to center fixed width page?
Posted 25 November 2011 - 05:12 AM
jwmollman, on 20 November 2011 - 03:25 AM, said:
This is my method:
For me, that's the quickest way for making a fixed-width container centered on the page.
#main {
width: 700px;
margin: 25px auto 25px auto;
padding: 15px;
border: 1px solid #848484;
}
For me, that's the quickest way for making a fixed-width container centered on the page.
This completely depends on the design. If you want one with top and bottom margin then of course it is correct. But as the question was how to centre, without showing any design it is safer to just do:
#main {
margin: 0 auto;
width: 900px;
}
By the way, if anyone ever needs it centred absolutely rather than relatively...
#main {
left: 50%;
position: absolute;
margin-left: -450px;
width: 900px;
}
I had a complicated design lately which that was the best way to do, took me a while to figure it out as it is not normal practise!
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote







|