Forum Moderators: not2easy

Message Too Old, No Replies

div alignment probs

         

lokjah

3:33 am on Feb 1, 2004 (gmt 0)

10+ Year Member



Hi everyone, this is my first post and its actually my first site. Im havin a consistent problem with div alignment, I have a container, and an id with a bg image. i wanted a subnav apart from my footer nav. my bg image has the section title in it ie- "content.advertising" i created a subnav and wanted to align it approx 10-15px under the section titles, which are in different places in each section so i set up 9 subnav positions ( 1 for each section) im getting about a 5-10 pixel difference in the alignment between mozilla and IE, and actually on 2 sections the alignment is pretty close in IE, but my code is the same on each page so im kinda confused as to whats wrong. im extremely new at this so pardon me if im not explaining myself in the right terminology. but maybe from my code someone can spot a problem... thanks alot, ive been reading this forum for the last week and see alot of awesome helping people.

the bit from my external css-

#container {
width:750px;
border:1px solid #000000;
margin:0px;
margin-left:auto;
margin-right:auto;
padding:0px;

.subnavappearance{
margin:0;
padding:0;
border-bottom:0px solid #000000;
letter-spacing:0pt;
}

.subnavappearance a{
font-family:helvetica, verdana, arial, sans-serif;
font-size:10pt;
font-weight:normal;
padding: 1px 1px;
text-decoration:none;
letter-spacing:0pt;
}

.subnavappearance a:link, .subnavappearance a:visited
{
color:#888888;
}

.subnavappearance a:hover
{
color:#cccccc;
}

#subnavposition1{
width:150px;
position:absolute;
margin-left:64px;
margin-top:385px;
padding:0px;
border:0px;
}

#advertising {
border-top: 1px solid #000;
border-bottom: 1px solid #000;
padding: 0px;
background-color: gray;
height:500px;
background: #000 url(http://clintfisherart.com/graphics/ad.jpg);
background-repeat:no-repeat;
}

my xhtml code (1.0 trans)

<?php include ("../header.inc");?>
<title>cFA advertising work</title>
<body>
<div id="container">
<div id="banner">&nbsp;</div>

<div id="advertising">&nbsp;

<div id="subnavposition1">
<div class="subnavappearance">
<a href="advertising/logo/">logo</a>
<a href="advertising/print/">print</a>
<a href="advertising/multimedia/">multimedia</a>
</div>
</div>
</div>
<div id="footer">
<?php include ("../botnav.inc");?>
</div>
</div>
</body>
</html>

TIA for any suggestions/comments

løk

auxum

3:58 am on Feb 1, 2004 (gmt 0)

10+ Year Member



though I too am new to posts here (though not to the web dev world)... I know that IE deals with spacing differently than most. I find it less relevant to make pages the same cross-browser, and more critical to make them similar while universally appealing.

sorry, not much help - I left my php server in my other trousers. only asp/winboxes at this office.
hope I can help more next time.

this is helpful:
[positioniseverything.net...]

auxum..

lokjah

7:58 pm on Feb 2, 2004 (gmt 0)

10+ Year Member



thanks for the imput, i read that article a bit ago.

would sure like it if someone can spot from my code what im doing wrong.

lokjah

1:48 am on Feb 9, 2004 (gmt 0)

10+ Year Member



~bump still hoping someone can help me on this..

thanks

løk

SuzyUK

8:44 am on Feb 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lokjah...

#subnavposition1{
width:150px;
position:absolute;
margin-left:64px;
margin-top:385px;
padding:0px;
border:0px;
}

when using absolute positioning margins should not be used. The correct attributes are ¦ top ¦ bottom ¦ right ¦ left ¦
as in the specific cco-ordinates.

e.g.
position:absolute;
left:64px;
top:385px;

I think this could be part of the trouble.. but I don't know if you margins set on the body element so can't be sure..

Secondly this will absolutely position the subnav in respect to the body element (which is why using margins might be unpredictable) but if you add position: relative; to your container div this will then mean that anything you position inside that div will take its co-ordinates from it and not the viewport.. so it might be easier to get a closer approxmation to your graphic.

Suzy

lokjah

8:46 pm on Mar 8, 2004 (gmt 0)

10+ Year Member



thank you suzy, im gonna try that.. sorry it took me a bit to respond i forgot about it after a bit...

:-)

løk

Strange

9:12 pm on Mar 8, 2004 (gmt 0)

10+ Year Member



Something I have also found helpful has been always setting the height and the width. You can also wrap your divs in another div area. These have helped me resolve issues I've had with IE and Netscape.

lokjah

5:13 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



hey thanks for the input...

could you give me an example of what the code of a wrapped div looks like?

lokjah

6:30 pm on Mar 15, 2004 (gmt 0)

10+ Year Member



suzy.. changing my containing div to relative fixed it..

woot!

and fortunately it didnt take alot of re aligning other things....

thanks again..