...

View Full Version : Alignment Problems CSS



thunder_light
11-20-2011, 05:12 PM
Hey,

I am having a fair few problems with designing my website. Firstly, when minimizing the window and narrowing it, the text mucks up and looks messy i.e. pushes everything down the page vertically and doesn't stay consistent?

Also for my header image, it changes with the size of the screen and shortens on larger screens..

Finally, I've used a wrapper with 20% margin-right and margin-left for the whole body, is there anyway to do this for the navigation links, as they are not exactly aligned in the center?

Header code:


#header {
background-image: url(images/island.jpg);
width: 75%;
height: 200px;
background-repeat:no-repeat;
background-size: 1000px 300px;
}



Wrapper Code:


#wrapper {
margin-right: 20%;
margin-left: 20%;
margin-top: 2%;
margin-bottom: 2%;
width: 75%;
}


Navigation code:


#nav {
float: left;
width: 75%;
height: 50px;
text-align: center;
background: #FFFF00;
color: #0000CC;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
font-weight: bold;
}

#nav ol a:visited {
color: #6633FF;
}
#nav ol a:active {
color: #FFFFFF;
background-color: #FF00CC;
}
#nav ol a:hover {
color: #FFFFFF;
background-color: #00FFFF;
}


Many Thanks

Excavator
11-20-2011, 05:22 PM
Hello thunder_light,
A percentage layout that works well can mess up as soon as some fixed pixel width content does not scale with the rest of the site.

In the bit of CSS you posted here, it seems a little odd that #wrapper would be 75% with 20% right/left margins. 75 plus 20 plus 20 = 115% width?

See the box model here (http://www.w3.org/TR/CSS2/box.html). The box model says that whatever you put inside an element cannot be larger than that element. margin/padding/border all count when figuring width/height.

A link to the test site would help, that way we can see what's happening.

thunder_light
11-20-2011, 05:32 PM
Thank you very much, I totally forgot about the box model! Sorry about that!
Okay, I may sound really silly, but I'm creating my website in Aptana and the links in the URL is from my drive (file:///J:/Design%20for%20the%20Internet/Website%20New/history.html) so how do I link this to you? I'm a newbie as you may have already guessed :(

Excavator
11-20-2011, 06:43 PM
You're not going to be able to link to a file on your hard drive. You need to upload it to a server - some free hosting here (http://www.google.com/search?q=free+hosting&sourceid=ie7&rls=com.microsoft:en-us:IE-Address&ie=&oe=).

blueapple
11-21-2011, 10:03 AM
Thanks excavator your free hosting link is quite valuable. Thanks again to sharing free hosting link



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum