1

我想在:hover.

三角形

.nav li {
  margin: 12px 0 0 20px; padding: 0;
  color: #000; font-weight: 700;
  display: inline-block;
}

.nav li+li:hover {
  background: #2f3343;
  padding: 5px 10px 5px 10px;
  margin: 0 -2px 0 20px;
  border-radius: 2px;
  font-weight: 700;
  border: none;
}

.nav .triangle {
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 12.5px 0 12.5px;
border-color: #000000 transparent transparent transparent;
}

我想把三角形放进去,:hover但它完全搞砸了。我需要设置一个特定的高度并添加一个位置吗?

4

2 回答 2

4

试试这个

我创建一个新的

.nav li {
  margin: 12px 0 0 20px; padding: 0;
  color: #000; font-weight: 700;
  display: inline-block;
    padding: 5px 10px 5px 10px;
 position:relative;
  border-radius: 2px;
}

.nav li:hover {
  background: #2f3343;

  border: none;
}

.nav li:hover:after {
    content:"";
border-style: solid;
    position: absolute;
left: 50%;
bottom: -10px;
    margin-left:-10px;
border-width: 10px 12.5px 0 12.5px;
border-color: #000000 transparent transparent transparent;
}

演示

于 2013-07-03T04:43:52.513 回答
2

试试下面的css:

.arrow {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #000;
    margin-left: 15px;
    display: none;
}
button:hover + .arrow {
    display: block;
}

我制作了一个与此类似的JSFiddle。看看并提供您的意见。

于 2013-07-03T04:42:04.053 回答