SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: multiple lists and css help needed

  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question multiple lists and css help needed

    Code:
    <div id="navigation">
    <ul id="navlist">
    <li id="active"></li>
    </ul>
    </div>
    that's the code for my list in xhtml. for css i've got this:
    Code:
    #navigation {
    	width: 138px;
    	}
    
    #navigation ul {
    	margin-left: 0;
    	padding-left: 0;
    	list-style-type: none;
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: x-small;
    	}
    
    #navigation li {
    	display: inline;
    	/* for IE5 and IE6 */
    	}
    
    
    #navigation a {
    	display: block;
    	padding: 2px;
    	width: 138px;
    	background-color: #7896AE;
    	border-bottom: 0px dotted #eee;
    	}
    
    #navigation a:link, #navlist a:visited {
    	color: #fff;
    	text-decoration: none;
    	}
    
    #navigation a:hover {
    	background-color: #4A7292;
    	color: #fff;
    	}
    now that works great but because i have multiple lists using the same code my page doesn't validate because i'm using the same id more than once. i've been trying to create a class for all of this but nothing i do seems to work. if anybody can switch around my stuff into a class i'd be most grateful as i've almost given up on it. thanks for the help.

  2. #2
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just make the entire thing a class.

  3. #3
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's what i'm trying to do. i don't know how to get it to work though.

  4. #4
    SitePoint Member
    Join Date
    May 2002
    Location
    Greeley, CO
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the following:
    Code:
    <ul class="nav-list">
    <li id="active"></li>
    </ul>
    Note that I've removed the div. Now CSS:
    Code:
    ul.nav-list {
    	width: 138px;
    	margin-left: 0;
    	padding-left: 0;
    	list-style-type: none;
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: x-small;
    	}
    
    ul.nav-list li {
    	display: inline;
    	/* for IE5 and IE6 */
    	}
    
    
    ul.nav-list a {
    	display: block;
    	padding: 2px;
    	width: 138px;
    	background-color: #7896AE;
    	border-bottom: 0px dotted #eee;
    	}
    
    ul.nav-list a:link, #navlist a:visited {
    	color: #fff;
    	text-decoration: none;
    	}
    
    ul.nav-list a:hover {
    	background-color: #4A7292;
    	color: #fff;
    	}
    This should work well.
    Heimidal.net - Take to the Skies

  5. #5
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <li id="active"></li>
    that still leaves in the multiple id's.

    you know, for your original one you can just have one id, and assign it to different attributes, this way you don't need to bother assigning them inside the tags themselves everytime
    Code:
    <div id="navigation">
    <ul>
    <li></li>
    </ul>
    </div>
    what you have is fine...except I never saw this "active" id in your code to begin with.

  6. #6
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't know how to incorporate all of that into one class. even then the div id wouldn't work because i want to use that same div multiple times. sorry for being stupid, but i need to see some code so i can understand what to do.

  7. #7
    SitePoint Wizard
    Join Date
    Jul 2004
    Location
    Minneapolis, MN
    Posts
    1,924
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just make it:

    ul {
    properties
    }

    li {
    properties
    }

  8. #8
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by charmedlover
    Just make it:

    ul {
    properties
    }

    li {
    properties
    }
    tried that but it doesn't make my lists actual blocks.

  9. #9
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,781
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Hi,

    Perhaps you could restate your current problem as it looked like you had answers to most of your questions

    What are the problems you need to overcome now? Do you have some revised code or are we still working on your original post?

    Hopefully we can solve your problem with a bit more info

    Paul

  10. #10
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://css.maxdesign.com.au/listamatic/vertical08.htm

    that's essentially what i started out with so that's what my lists look like. i want all of that in a class so instead of calling id's i just call a class or classes. i want the look to be the same but the ability to use it multiple times.

  11. #11
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,781
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Hi,

    Well most of the answers have been given above so I must have missed something somewhere

    Try this anyway:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    ul.navlist {
     margin-left: 0;
     padding-left: 0;
     list-style-type: none;
     font-family: Arial, Helvetica, sans-serif;
     font-size: x-small;
     width: 138px;}
    ul.navlist li {
     display: inline;
     /* for IE5 and IE6 */
     }
    
    ul.navlist a {
     display: block;
     padding: 2px;
     background-color: #7896AE;
     border-bottom: 0px dotted #eee;
     }
    * html ul.navlist a {height:1%}/* for ie */
    ul.navlist a:link, ul.navlist a:visited {
     color: #fff;
     text-decoration: none;
     }
    ul.navlist a:hover {
     background-color: #4A7292;
     color: #fff;
     }
    </style>
    </head>
    <body>
    <ul class="navlist">
    <li class="active"><a href="#" class="current">Item one</a></li>
    <li><a href="#">Item two</a></li>
    <li><a href="#">Item three</a></li>
    <li><a href="#">Item four</a></li>
    <li><a href="#">Item five</a></li>
    </ul>
    <ul class="navlist">
    <li class="active"><a href="#" class="current">Item one</a></li>
    <li><a href="#">Item two</a></li>
    <li><a href="#">Item three</a></li>
    <li><a href="#">Item four</a></li>
    <li><a href="#">Item five</a></li>
    </ul>
    <ul class="navlist">
    <li class="active"><a href="#" class="current">Item one</a></li>
    <li><a href="#">Item two</a></li>
    <li><a href="#">Item three</a></li>
    <li><a href="#">Item four</a></li>
    <li><a href="#">Item five</a></li>
    </ul>
     
    </body>
    </html>
    Hope that helps.

    Paul

  12. #12
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    thank you so much! i'm sorry for sounding so ignorant but i honestly did try to get things working but i was having no luck. it seems every css tutorial i find doesn't really go in depth enough or is specific enough for what i want to do. you've helped me before and i really appreciate that.

  13. #13
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm glad you got this worked out

Bookmarks

Posting Permissions

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