www.webdeveloper.com
Results 1 to 3 of 3

Thread: CSS navbar rollovers break in IE

  1. #1
    Join Date
    Nov 2005
    Posts
    2

    CSS navbar rollovers break in IE

    Hello,

    Can anyone tell me why these CSS rollovers don't return to the normal state in IE? Here's the link

    Here's the code:

    <html>
    <head><link href="style.css" rel="stylesheet" type="text/css" /></head>
    <body>
    <div id="mainnavbar"><ul><li><a href="../index.html">Home</a></li><li><a href="#">Link 1</a></li><li><a href="#">Link 2</a></li><li><a href="#">Link 3</a></li><li><a href="#">Link 4</a></li><li id="portallink"><a href="#">Link 5</a></li></ul>
    </div>
    </body>
    </html>

    CSS:

    a:link, a:visited {
    font: bold 10px Verdana, Arial, Helvetica, sans-serif;
    color: #666;
    text-decoration: none;
    }
    div#mainnavbar {
    background-color: #666;
    width: 750px;
    padding: 0;
    height: 20px;
    margin: 1px 0;
    }
    div#mainnavbar ul {
    list-style-type: none;
    padding: 0;
    text-align: center;
    margin: 0;
    }
    div#mainnavbar ul li a, div#mainnavbar ul li a:visited {
    color: #CCC;
    display: block;
    height: 20px;
    line-height: 20px;
    padding: 0;
    margin: 0;
    width: 125px;
    }
    div#mainnavbar ul li {
    float: left;
    }
    div#mainnavbar ul li a:hover, div#mainnavbar ul li#portallink a:hover {
    text-decoration: none;
    color: #333;
    background-image: url(images/bg_drk.gif);
    width: 125px;
    margin: 0;
    padding: 0;
    }



    Thanks!

  2. #2
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    I have no idea what's causing that, however, there is a work-around.

    Code:
    div#mainnavbar ul li a, div#mainnavbar ul li a:visited {
      padding: 0px;
      display: block;
      margin: 0px;
      width: 125px;
      color: #ccc;
      line-height: 20px;
      height: 20px;
      background-color: #666;
    }
    div#mainnavbar ul li {
      float: left;
      background-image: url(images/bg_drk.gif);
    }
    div#mainnavbar ul li a:hover, div#mainnavbar ul li#portallink a:hover {
      padding: 0px;
      background-color: transparent;
      margin: 0px;
      width: 125px;
      color: #333;
      text-decoration: none;
    }
    CSS Background Image Switching
    Last edited by Kravvitz; 11-17-2005 at 05:04 PM.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Just add:
    Code:
    #mainnavbar ul li a, #mainnavbar ul li a:visited {
        background:#666;
    If you change the :hover background the 'normal' state has to be changed too.

    Selectors with id are unique, so don't require any tags before them. It only slows the css parsing.
    Not div#mainnavbar ul li a but #mainnavbar ul li a
    Not div#mainnavbar ul li#portallink a:hover but #portallink a:hover
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles