chengtongpo 发表于 2021-3-11 11:29

纯css实现小箭头或三角形标志

作为一名前端工程师,工作中免不了要使用css制作一些小箭头、三角形之类的标志。下面我就来为大家分享下纯css制作小箭头、三角形等标志的方法。


实现小箭头:
.arrow{

    width: 20px;

    height: 20px;

    margin-top: 50px;

    margin-left: 50px;

    border-top: 1px solid #000;

    border-left: 1px solid #000;

    transform: rotate(45deg);/*旋转角度*/

}
<span style="color: rgb(0, 0, 0); font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;PingFang SC&quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: rgb(238, 238, 238);">实现三角形:</span>如何让多个元素在一行显示?

(1)display:inline把元素转化为行内元素,但是宽高属性不起作用

(2)display:inline-block可以让元素在一行显示,但是他会受空格、换行键的影响,会有默认间距

解决办法:

1、去掉空格和换行键的影响 让标签全都在一行(这种方法不推荐,阅读性不好)

2、给加了display:inline-block属性的元素的父元素加一个属性font-size:0

display:inline-block在ie6 7下不兼容的解决办法?

dispaly:inline;//css hack ie浏览器可以识别

zoom:1;//触发css hack的layout3、利用浮动floa:left/right,但是需要清浮动

页: [1]
查看完整版本: 纯css实现小箭头或三角形标志