箭头没有显示使用:之后

时间:2016-05-03 00:14:03

标签: css

我一直在尝试使用类.b向div添加箭头,但是无法正常工作,我无法找出原因。有没有人有任何想法?

#nextgoal {
    width: 100%;
    text-align: center;
}

    #nextgoal .a {
        border: 1px solid #42aacc;
        height: 54px;
        width: 54px;
        border-radius: 50%;
        background-color: #fff;
        color: #42aacc;
        font-weight: bold;
        padding: 8px 10px 10px 12px;
        font-size: 30px;
        display: inline-block;
        position: relative;
        float: left;
        z-index: 1000;
    }

    #nextgoal .b {
        margin-left: -18px;
        margin-top: 6px;
        height: 49px;
        background-color: #42aacc;
        display: inline-block;
        padding: 10px 7px 3px 27px;
        color: white;
        position: relative;
        display: inline-block;
        float: left;
        z-index: 10;
    }

#nextgoal.b :after {
    background: #42aacc;
    bottom: 100%;
    color: #42aacc;
    display: block;
    padding: 2px;
    pointer-events: none;
    position: absolute;
    border: dotted 1px #42aacc;
    font-size: 11px;
    border-radius: 5px;
}
<div id="nextgoal" style="margin-top:1em;"><div class="a">AA</div><div class="b">Next Goal</div></div>

1 个答案:

答案 0 :(得分:1)

你的选择器不正确,并且content:'';缺少有效生成你的伪元素,试试这个:

#nextgoal .b:after {
  content: '';

&#13;
&#13;
#nextgoal {
  width: 100%;
  text-align: center;
}
#nextgoal .a {
  border: 1px solid #42aacc;
  height: 54px;
  width: 54px;
  border-radius: 50%;
  background-color: #fff;
  color: #42aacc;
  font-weight: bold;
  padding: 8px 10px 10px 12px;
  font-size: 30px;
  display: inline-block;
  position: relative;
  float: left;
  z-index: 1000;
}
#nextgoal .b {
  margin-left: -18px;
  margin-top: 6px;
  height: 49px;
  background-color: #42aacc;
  display: inline-block;
  padding: 10px 7px 3px 27px;
  color: white;
  position: relative;
  display: inline-block;
  float: left;
  z-index: 10;
  overflow: visible;
}
#nextgoal .b:after {
  content: '';
  background: #42aacc;
  bottom: 100%;
  color: #42aacc;
  display: block;
  padding: 2px;
  pointer-events: none;
  position: absolute;
  border: dotted 1px #42aacc;
  font-size: 11px;
  border-radius: 5px;
}
&#13;
<div id="nextgoal" style="margin-top:1em;">
  <div class="a">AA</div>
  <div class="b">Next Goal</div>
</div>
&#13;
&#13;
&#13;

它显然不是一个箭头而是一个点,因为边界在这里显示...