Re: margin not working
On 2008-03-14 10:15:21 +0000, Ben C <spamspam@spam.eggs> said:
> On 2008-03-14, raj <raj@nospam.com> wrote:
>> Hi everyone,
>>
>> I'm a newbie and can;t get this code to work. It is supposed to center
>> the text block within the wrap, but the centering won't work.
>
> You can't centre a float. It floats to one side or the other.
>
>> I'm quite
>> new to CSS and have tried to fix this now for a long time. Can anyone
>> see where I'm going wrong?
>>
>> Thank you in advance.
>>
>> Raj
>>
>>
>> #wrap{
>> background: #faf1d4 url(../images/bg.gif) repeat-x;
>> }
>>
>> #text{
>> float: left;
> ^^^^^^^^^^^
>
> Just get rid of this line and it should centre OK.
>
>> width: 1000px;
>> padding-left: 20px;
>> padding-right: 20px;
>> background-color: #f5e9cc;
>> margin-left: auto;
>> margin-right: auto;
>> }
>>
>>
>> the relevant html code is:
>>
>> <div id="wrap">
>> <div id="text">
>> <p>abcdef</p>
>> </div>
>> </div>
That's fixed it.
Thanks Ben
|