Results 1 to 2 of 2

Thread: help with nav

  1. #1
    Join Date
    Jan 2010
    Posts
    115

    help with nav

    So I have the html code
    <div id="navagation">
    <ul>
    <li><a href="http://answermyhw.webs.com/bantingriver.html">Home</a></li>
    <li><a href="http://answermyhw.webs.com/c5551.html">Chatten</a></li>
    <li><a href="http://answermyhw.webs.com/b4639.html">Blizzard</a></li>
    <li><a href="http://answermyhw.webs.com/t7758.html">Therasse
    </a></li>
    <li><a href="http://answermyhw.webs.com/a991.html">About</a></li>
    <li><a href="http://answermyhw.webs.com/d4745.html">Disclaimer</a></li>
    </ul>
    </div>
    and the CSS
    #navagation {
    width: 996px;
    height: 25px;
    background:#98bf21;
    overflow: hidden;
    border-left: solid 2px;
    border-right: solid 2px;
    margin-left: auto;
    margin-right: auto;
    }

    ul
    {
    list-style-type:none;
    margin:0;
    padding-left: 100px;
    overflow:hidden;
    }
    li
    {
    float:left;
    }
    a:link,a:visited
    {
    display:block;
    width:120px;
    font-weight:bold;
    color:#FFFFFF;
    background-color:#98bf21;
    text-align:center;
    padding:4px;
    text-decoration:none;
    }
    a:hover,a:active
    {
    background-color:#7A991A;
    }
    But the problem is the CSS code makes ALL the links on the website in to a nav styled link. How do you limit the code to only work on #navagation
    (i know it's spelled wrong)

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    When you have styles like
    Code:
    ul { width: 300px; }
    li { color: red; }
    those styles affect all ul and li tags on your page, so put extra styles AFTER them in your stylesheet like
    Code:
    #navagation ul
    {
    list-style-type:none;
    margin:0;
    padding-left: 100px;
    overflow:hidden;
    }
    #navagation li
    {
    float:left;
    }
    #navagation a:link, #navagation a:visited
    {
    display:block;
    width:120px;
    font-weight:bold;
    color:#FFFFFF;
    background-color:#98bf21;
    text-align:center;
    padding:4px;
    text-decoration:none;
    }
    #navagation a:hover, #navagation a:active
    {
    background-color:#7A991A;
    }
    where the id (or class) will restrict the styles to that id (or class). Note that where you have two or more style names for a style you have to repeat the id or class for all of them like #navagation a:hover, #navagation a:active
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Similar Threads

  1. IE9 and Round Corners
    By cla1067 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 21 Sep 2010, 03:55 AM
  2. CSS Rendering Horizontal Nav Vertically in All Browsers
    By shelzmike in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 18 Jun 2009, 02:41 PM

Posting Permissions

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