开发者

Menu triangle/arrow issue (pure CSS)

I have a triangle next to menu items, using pure CSS. It works flawlessly in Internet Explorer and Firefox but Chrome crops the bottom of the开发者_如何学JAVA arrow. Here's some screenshots of the issue:

Menu triangle/arrow issue (pure CSS)

Menu triangle/arrow issue (pure CSS)

Menu triangle/arrow issue (pure CSS)

Here is the CSS I'm using:

/*menu arrows */

.arrowsprite {
    width:0px; 
    height:0px; 
    border-left:5px solid transparent;
    border-right:5px solid transparent;
    border-top:5px solid #444444;
    font-size:0px;
    line-height:0px;
    top:-2px;
    position:relative;
}

.arrowspriteselected {
    width:0px; 
    height:0px; 
    border-left:5px solid transparent;
    border-right:5px solid transparent;
    border-top:5px solid #fff;
    font-size:0px;
    line-height:0px;
    top:-2px;
    position:relative;
}

.leftish li:hover .arrowsprite {
    border-top:5px solid #444444;
}


.leftish li:hover .arrowspriteselected {
    border-top:5px solid #444444;
}

The HTML is:

<li>Wanted <span class="arrowsprite"></span></li>

Does anyone see any glaring problems in my CSS?


Try setting display to inline-block for your .arrowsprite rule. See this fiddle for an example.

.arrowsprite {
    width:0px;      
    height:0px;      
    border-left:5px solid transparent;     
    border-right:5px solid transparent;     
    border-top:5px solid #444444;     
    font-size:0px;     
    line-height:0px;     
    top:-2px;     
    position:relative;
    display:inline-block;
}

It's working for me in Chrome 14.0.803.0 dev.


I'm not able to reproduce what you see in Chrome 12.0.742.112. For me, the span didn't even show up with that CSS and HTML. However, I tried putting in a non-breaking space, and then I was able to see it and it displayed fine.

<li>Wanted <span class="arrowsprite">&nbsp;</span></li>

Here's a fiddle to compare with and without the non-breaking space. Notice that on Firefox at least the   method gives more space (no pun intended), so see if you can still make it do what you want. If you can't, the next thing to try would be a float for your list elements (See this question for why).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜