IE bug - floating anchors

Discussion in 'CSS' started by blueparukia, Dec 1, 2007.

  1. #1
    OK, my HTML

    
    <ul id="navbar">
       <li><a href="">Link 1</a></li>
       <li><a href="">Link 2</a></li>
       <li><a href="">Link 3</a></li>
    </ul>
    
    Code (markup):
    My CSS:

    
    #navbar li a
    {
    height:65px;
    padding-top:45px;
    float:left;
    width:130px;
    text-align:center;
    color:#000;
    font-weight:bold;
    font-size:large;
    }
    
    #navbar li a:hover
    {
    background:#FFFFFF;
    }
    Code (markup):
    The issue is the individual list items look like a staircase in IE, with Link 1 being at the top, link 2 being a few pixels beside and below it, and link 3 below and beside that.

    I think somethings screwed up with the margins,

    Thanks,

    BP
     
    blueparukia, Dec 1, 2007 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Stomme poes, Dec 2, 2007 IP
  3. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #3
    Yeah, I floated the lis, but a{width: and height:} don't seem to work in Opera, and it happens on IE7 as well, don't worry abut it, I'll find something else.
     
    blueparukia, Dec 2, 2007 IP
  4. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #4
    An <a>nchor is an inline element. You have to set the display value to 'block' to give it dimensions (alternatively you could float it)
     
    soulscratch, Dec 2, 2007 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yeah you could float them both, Parukia. But if you took my second code with display:block and add height and width to the a, Opera still doesn't obey?

    Leo (a guy who was here) started floating everything in his menus so he could make them bounce like those Javascript menus. So I've seen where they're both floated. But I can also guess that some browser, somewhere, won't like floats in floats and will puke on it.
     
    Stomme poes, Dec 2, 2007 IP
  6. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #6
    OK, I'll test with a block display,

    Thanks all,

    BP
     
    blueparukia, Dec 3, 2007 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Make the LI display:inline. The default behavior of LI's in IE (which is a 'special' - neither inline or block there) is what's messing things up.

    Also, do NOT use a named font size with a px height/width container - that WILL end up breaking on large font machines.... though I probably wouldn't be specifying widths on those EITHER...
    #navbar {
    	float:left;
    	width:100%; /* make sure this wraps the anchor if you want to apply styling */
    	list-style:none;
    	font:bold 18px/20px arial,helvetica,sans-serif;
    }
    
    #navbar li {
    	display:inline;
    }
    
    #navbar a {
    	float:left;
    	padding:45px 8px 0;
    	color:#000;
    	text-decoration:none;
    	text-align:center;
    }
    Code (markup):
    Should do pretty much what you are looking for.
     
    deathshadow, Dec 3, 2007 IP