Forum Moderators: not2easy

Message Too Old, No Replies

Problems with Firefox/Netscape/Opera

Can anyone suggest what is happening here?

         

BeeDeeDubbleU

8:03 pm on Oct 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have just noticed a problem on my site. I use the following code to centre Adsense ad units within a div.

<p style="width:250px; padding:8px; margin-left: auto; margin-right: auto;">

I have just noticed that the other browsers are centering it in the window as opposed to the div. Any suggestions on how to get round this?

createErrorMsg

8:13 pm on Oct 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Auto margins are calculated based on the remaining available space in the parent container, so the most likely issue is that the div containing the <p> is wider than you think it is. Check to make sure all your tags are correctly closed and that the div has an explicit width that causes it's width to be less than the page width.

It probably wouldn't hurt to post the markup and css for the container div, either.

cEM

BeeDeeDubbleU

9:02 pm on Oct 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hopefully you can understand this?

This is the CSS for the div ...

div.content {
width: 550px;
position: relative;
background-color: #FFFFFF;
margin: 0;
border: solid 1px #ccf;
font-family: Verdana,Arial,Helvetica,sans-serif;
padding: 15px 0px 5px 10px;
}

This is the abbreviated markup ...

<div class="content">
<p style="width:250px; padding:8px; margin-left: auto; margin-right: auto;">
(Adsense script)
(Adsense script)
(Adsense script)
(Adsense script)
</p>
<p class="content"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. </p>
</div>

As you can see the content div appears to be closed properly but could there be some kind of a conflict between the "width" declarations in the CSS and the inline style?

(Apologies for my ignorance but I only recently got into CSS.)

createErrorMsg

9:22 pm on Oct 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That code centers the <p> just fine for me on a test page. Could something else be interfering?

cEM

BeeDeeDubbleU

9:56 pm on Oct 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for looking but it's almost 11pm here so I'm pulling the plug. I'll have a look again tomorrow.

BeeDeeDubbleU

2:09 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Could this be caused by nested Divs?

SuzyUK

2:34 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



don't think so, unless they're not closed/nested properly

thoughts:
have you anything in your CSS that targets/styles an iframe?
and are you sure your content div has a closing tag..

I suggest validating your HTML [validator.w3.org] and CSS [jigsaw.w3.org] just incase there's some markup problems causing confusion..

I also tested your code above with a 234x60 ad script and can confirm that it's working fine

Suzy

BeeDeeDubbleU

9:34 pm on Oct 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My thanks to Optirex for helping me to fix this.

The problem was that ...
<p style="width:250px; padding:8px; margin-left: auto; margin-right: auto;">

should have been ...

<p style="width:250px;padding:8px;margin:10px;">

It's now working OK.