html <a> not clickable inside menu</a>

时间:2013-10-16 23:28:40

标签: html css twitter-bootstrap

我有以下菜单,<a>不可点击,我相信这是一个z-index问题,但无法修复它。 html也有意义,尝试在右边创建一个带有连接矩形的圆圈。然后当它下降时它将完全连接并填写。我正在使用bootstrap 2.3.2。

jsfiddle link

HTML

<div class="row-fluid">
    <div class="span2"></div>
    <div class="span7 center"></div>
    <div class="span3">
        <div class="rightMenu visible-desktop">
            <div class="scoreBadge">--</div>
            <div class="userBadge"> <a href="/home">username ▼</a>

            </div>
            <ul>
                <li>    <a href="/settings">settings</a>

                </li>
                <li>    <a href="/logout" class="grey">log out</a>

                </li>
            </ul>
        </div>
    </div>
</div>

CSS

.rightMenu{
   position: absolute;
   right: 0;
   top: 8px;
   margin-top: 10px;
   min-width: 65px;
}
.rightMenu ul {
    display: none;
    list-style: none;
    text-align: left;
    position: relative;
    left: -10px;
    top: -30px;
    background-color: #4b86a1;
    color: white;
    z-index: -2;
    margin-left: 10px;
    padding: 20px 10px 10px 10px;
}
.rightMenu ul li {
}
.rightMenu:hover ul {
    display: block;
}
.rightMenu ul a {
    color: white;
}
.scoreBadge {
    display: inline-block;
    background: white;
    color: #4B86A1;
    height: 30px;
    width: 30px;
    border: 2px solid #fcdf05;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    vertical-align: middle;
    font-size: 18px;
}
.userBadge {
    display: inline-block;
    background-color: #4b86a1;
    vertical-align: middle;
    padding-left: 10px;
    line-height: 30px;
    min-width: 49px;
    position: relative;
    left: -10px;
    -webkit-border-top-right-radius: 8px;
    -webkit-border-bottom-right-radius: 8px;
    -moz-border-radius-topright: 8px;
    -moz-border-radius-bottomright: 8px;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    text-align: right;
    z-index: -1;
}
.userBadge > a {
    padding: 0 5px 0 5px;
    line-height: 25px;
}
#usrName {
    color: white;
    font-size: 10pt;
    font-weight: normal;
    text-transform: uppercase;
}

2 个答案:

答案 0 :(得分:4)

在你的css

.rightMenu ul {
    display: none;
    list-style: none;
    text-align: left;
    position: relative;
    left: -10px;
    top: -18px;
    background-color: #4b86a1;
    color: white;
    z-index: -2; /* this is the problem */
    margin-left: 10px;
    padding: 20px 10px 10px 10px;
}

只需从-移除z-index: -2;即可。此外,没有z-index: 2;它似乎工作正常,那么为什么不删除z-index属性? example herez-index:2)和another example(不含z-index属性)。

答案 1 :(得分:0)

我为你解决了问题,看到在类.rightMenu ul中将z-index更改为2