<hr />用箭头指向css中的箭头

时间:2017-08-01 07:29:26

标签: css

hr或div行,中间有向上箭头。与此类似(Down arrow

我试过了。看起来我无法将箭头移动到正确的位置。

我的代码:

&#13;
&#13;
div.hr {
    width:100%;
    height: 1px;
    background: #7F7F7F;
    position:relative;
    margin-top:15px;
}
div.hr:after {
    content:'';
    position: absolute;
    border-style: solid;
    border-width: 0 15px 15px;
    border-color: #FFFFFF transparent;
    display: block;
    width: 0;
    z-index: 1;
    top: 5px;
    left: 50%;
}
div.hr:before {
    content:'';
    position: absolute;
    border-style: solid;
    border-width: 0 15px 15px;
    border-color: #7F7F7F transparent;
    display: block;
    width: 0;
    z-index: 1;
    top: 4px;
    left: 50%;
}
&#13;
<div class="hr"></div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

以下是您提供的示例的修改版本,箭头朝上,而不是向下。希望这会有所帮助。

DEMO:Codepen

CSS:

div.hr {
    width:100%;
    height: 1px;
    background: #7F7F7F;
    position:relative;
    margin-top:15px;
}
div.hr:after {
    content:'';
    position: absolute;
    border-style: solid;
    border-width: 0 15px 15px;
    border-color: #FFFFFF transparent;
    display: block;
    width: 0;
    z-index: 1;
    top: -14px;
    left: 50%;
}
div.hr:before {
    content:'';
    position: absolute;
    border-style: solid;
    border-width: 0 15px 15px;
    border-color: #7F7F7F transparent;
    display: block;
    width: 0;
    z-index: 1;
    top: -15px;
    left: 50%;
}

HTML:

<div class="hr"></div>