...

View Full Version : CSS word spacing - padding? margin?



intcon
03-29-2009, 10:07 PM
Hello!

I have three a footer, with 3 nav word groupings..ie, join our newsletter, site map, about me....i need to space them evenly across the bottom of the footer - one on the left, one to the right and one in the center, using CSS. I'm a newbie to CSS. =) so bear with me.....i just don't know what piece of code i'm looking for! do i set a margin for the class style and on the middle word have it have so much of a margin to the left and right? or padding? or ....there's so much to choose from, i'm not quite sure what's the best (read easiest) solution to get them apart.

help?

thanks!

carrie

Excavator
03-29-2009, 10:26 PM
hello intcon,
A very basic solution here -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
font: 14px "Comic Sans MS";
background: #FC6;
text-align: center;
}
* {
margin: 0;
padding: 0;
outline: none;
border: none;
}
#container {
width: 800px;
margin: 30px auto;
padding: 200px 0 0 0;
background: #999;
overflow: auto;
}
#footer {
height: 30px;
line-height: 30px;
background: #C90;
}
#footer a {
margin: 0 10px;
}
#footer a:hover {
color: #f00;
}
</style>
</head>
<body>
<div id="container">
<div id="footer">
<a href="">join our newsletter</a>
<a href="">site map</a>
<a href="">about me</a>
<!--end footer--></div>
<!--end container--></div>
</body>
</html>

Let me know if that's messed up in IE6... I didn't check with that browser.

timgolding
03-29-2009, 10:36 PM
Theres lots of ways of doing this you should put them in divs. You can use relative positioning is one way and an other way is using floated divs. Theres also probably many more. Here is my relative positioning method

CSS:


.left
{
line-height: 1.25em;
test-align:left;
}

.center
{
text-align:center;
line-height: 1.25em;
position:relative;
top:-1.25em;
}

.right
{
text-align:right;
line-height: 1.25em;
position:relative;
top:-2.5em;
}


HTML:


<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>


And the float method

CSS:


.left
{
test-align:left;
float:left;
clear:none;
}

.center
{
text-align:center;

}

.right
{
text-align:right;
float:right;
clear:none;
}


HTML



<div class="right">right</div>
<div class="left">left</div>
<div class="center">center</div>


Notice in this method the right div comes before the left?

intcon
03-29-2009, 10:37 PM
thanks excavator....i added in the code, but the nav is just spaced like
word word word
and i need it to be
well turns out i can't post it the way i want...but it needs to take the whole width of the bottom, 800 px, with one word grouping on the left, one in the middle and one on the right
sorry, if i didn't explain myself well....i've been at it 7 hours trying to find a solutions and my brain is fried.:p

carrie

timgolding
03-29-2009, 11:09 PM
thanks excavator....i added in the code, but the nav is just spaced like
word word word
and i need it to be
well turns out i can't post it the way i want...but it needs to take the whole width of the bottom, 800 px, with one word grouping on the left, one in the middle and one on the right
sorry, if i didn't explain myself well....i've been at it 7 hours trying to find a solutions and my brain is fried.:p

carrie

In that case my method works fine

intcon
03-29-2009, 11:09 PM
thanks tim! that turned out just fine...i did the float, and after i changed test-align; to text-align :p it turned out just the way i wanted.

thanks for all your speedy help, you'll be seeing me again soon in the "how did my background end up over there?" thread... :p

carrie

Excavator
03-29-2009, 11:09 PM
Try playing with the bit in red and see if that gets you where you want -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
font: 14px "Comic Sans MS";
background: #FC6;
text-align: center;
}
* {
margin: 0;
padding: 0;
outline: none;
border: none;
}
#container {
width: 800px;
margin: 30px auto;
padding: 200px 0 0 0;
background: #999;
overflow: auto;
}
#footer {
height: 30px;
line-height: 30px;
background: #C90;
}
#footer a {
margin: 0 50px;
}
#footer a:hover {
color: #f00;
}
</style>
</head>
<body>
<div id="container">
<div id="footer">
<a href="">join our newsletter</a>
<a href="">site map</a>
<a href="">about me</a>
<!--end footer--></div>
<!--end container--></div>
</body>
</html>

Floating left and right isn't going to do anything in IE6, not without giving it a width.
You could try putting margin on only the center link, that would save putting divs around everything (http://csscreator.com/?q=divitis).
Like this -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
font: 14px "Comic Sans MS";
background: #FC6;
text-align: center;
}
* {
margin: 0;
padding: 0;
outline: none;
border: none;
}
#container {
width: 800px;
margin: 30px auto;
padding: 200px 0 0 0;
background: #999;
overflow: auto;
}
#footer {
height: 30px;
line-height: 30px;
background: #C90;
}
#footer a {
color: #00f;
}
#footer a:hover {
color: #f00;
}
#mid {
margin: 0 280px 0 220px;
}


</style>
</head>
<body>
<div id="container">
<div id="footer">
<a href="">join our newsletter</a>
<a href="" id="mid">site map</a>
<a href="">about me</a>
<!--end footer--></div>
<!--end container--></div>
</body>
</html>
Again, still not sure how IE6 handles that. My IE6 box is down for a bit.

timgolding
03-29-2009, 11:13 PM
and after i changed test-align; to text-align :p

Ah... silly mistake lol :) well glad it worked the float method is nicer code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum