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

2021-03-12,

/2021/03/893905e0.jpg

作为一名前端工程师,工作中免不了要使用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);/*旋转角度*/
}
<div class="arrow"></div>

实现三角形:

.triangle{
    width: 0;
    height: 0;
    border-width: 100px;
    border-style: solid;
    border-color: red transparent transparent transparent;
    transform:rotate(45deg);
}
<div class="triangle"></div>

(免费视频教程:css视频教程)

如何让多个元素在一行显示?

(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的layout

3、利用浮动floa:left/right,但是需要清浮动

相关推荐:CSS教程

以上就是纯css实现小箭头或三角形标志的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《纯css实现小箭头或三角形标志.doc》

下载本文的Word格式文档,以方便收藏与打印。