Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    89
    Thanks
    27
    Thanked 0 Times in 0 Posts

    CSS word spacing - padding? margin?

    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

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    hello intcon,
    A very basic solution here -
    Code:
    <!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.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    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:
    Code:
    .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:
    Code:
    <div class="left">left</div>
    <div class="center">center</div>
    <div class="right">right</div>
    And the float method

    CSS:
    Code:
    .left
    {
    test-align:left;
    float:left;
    clear:none;
    }
    
    .center
    {
    text-align:center;
    
    }
    
    .right
    {
    text-align:right;
    float:right;
    clear:none;
    }
    HTML
    Code:
    <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?
    Last edited by timgolding; 03-29-2009 at 11:09 PM.
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    New Coder
    Join Date
    Mar 2009
    Posts
    89
    Thanks
    27
    Thanked 0 Times in 0 Posts
    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.

    carrie

  • #5
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by intcon View Post
    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.

    carrie
    In that case my method works fine
    You can not say you know how to do something, until you can teach it to someone else.

  • #6
    New Coder
    Join Date
    Mar 2009
    Posts
    89
    Thanks
    27
    Thanked 0 Times in 0 Posts
    thanks tim! that turned out just fine...i did the float, and after i changed test-align; to text-align 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...

    carrie

  • #7
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Try playing with the bit in red and see if that gets you where you want -
    Code:
    <!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.
    Like this -
    Code:
    <!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.
    Last edited by Excavator; 03-30-2009 at 01:11 AM.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #8
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by intcon View Post
    and after i changed test-align; to text-align
    Ah... silly mistake lol well glad it worked the float method is nicer code.
    You can not say you know how to do something, until you can teach it to someone else.

  • Users who have thanked timgolding for this post:

    intcon (03-30-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •