箭头无法在CSS中正确显示

时间:2014-08-20 09:45:20

标签: html css html5 css3 css-shapes

我正在努力实现向下的箭头...... 现在它显示为梯形,CSS箭头代码存在一些问题...... 在下面提供我的代码.....

输出

https://docs.google.com/file/d/0B3IBJKENGE7RRFR1WHZDYTF6LTQ/edit

<div class="icon__controls__controls">
    <div><a href="#" id="picture-zoom"><i class="zoom-out"></i></a>
 <a href="#" id="picture-threesixty"><i class="icon-threesixty"></i></a>

    </div>
</div>

CSS:

.icon__controls__controls {
    float: left;
    display: block;
    margin-right: 2.1276595745%;
    width: 36.170212766%;
    margin-left: 38.2978723404%;
    margin-top: 10px;
    margin-bottom: 30px;
    text-align: center;
}

.icon__controls__controls:last-child {
    margin-right: 0;
}

.icon__controls__controls [class^=icon-] {
    font-size: 20px;
    font-size: 1.25rem;
    display: inline-block;
    vertical-align: baseline;
    zoom: 1;
    *display: inline;
    *vertical-align: auto;
    color: #666;
    margin: 0 5px;
    vertical-align: top;
}

.icon__controls__controls .zoom-out {
    color: red;
}

.icon__controls__controls:after {
    display: none;
    content: '';
    z-index: 3;
    border: 50px solid transparent;
            /* border-left: 5px solid transparent;
                    border-right: 5px solid transparent;

                    border-bottom: 5px solid black; */
}

.icon__controls__controls:after {
    border-top-color: #ef6f00;
}

.icon__controls__controls.active:after {
    display: block;
}

3 个答案:

答案 0 :(得分:3)

LIVE DEMO

enter image description here 这基本上就是你需要了解它的工作原理:

型:

.arrow{
    width:20px;
    height:20px;
    position:relative;
}
.arrow:before{
    content:'';
    position:absolute;
    top:0;
    left:0;
    width:0;
    height:0;
    border-left:20px solid transparent;
    border-right:20px solid transparent;
    border-bottom:0px solid transparent;
    border-top:20px solid orange;
}

HTML:

 <div class=arrow><div>

如果您希望它仅指向切换topbottom

    border-top:0px solid transparent;
    border-bottom:20px solid orange;

leftright相同。

我希望这有助于您了解如何创建箭头。

答案 1 :(得分:1)

基本样本:

<div class="arrowBorder"></div>

.arrowBorder {
  height : 0px;
  width : 0px;
  border-top: 50px solid red;
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
}

http://jsbin.com/qusecu/4/watch?html,css,output

了解更多 - CSS剪辑或屏蔽

答案 2 :(得分:0)

您应该会发现下面的内容更简单
CSS

.arrow{
    box-sizing:border-box;
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    -o-box-sizing:border-box;
    -ms-box-sizing:border-box;
    width:20px;
    height:20px;
    position:relative;
      border-left:20px solid transparent;
    border-right:20px solid transparent;
    border-bottom:20px solid transparent;
    border-top:20px solid orange;
}

HTML

<div class=arrow><div>