我们在网页中会经常看到一些小三角,有的是使用图片,但是这种的加载速度相比文字写出来的慢一些,下面就是我用简单的css写出来的小三角。后续还会添加一些其他的方式。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.fl{
width: 125px;
height: 30px;
line-height: 30px;
background-color: gold;
}
i,s{
text-decoration: none;/*去除下划线*/
}
.dt{
padding: 0 20px;
position: relative;/*父元素设置相对位置*/
}
.dt i{
font: 400 15px/15px "宋体";
position: absolute;
top: 13px;
right: 3px;
width: 15px;
height: 7px;
overflow: hidden;
}
.dt s{
position: absolute;
top: -8px;
left: 0;
}
</style>
</head>
<body>
<div class="fl">
<div class="dt">
城市:杭州
<i><s>◇</s></i>
</div>
</div>
</body>
</html>
本文介绍了一种使用CSS创建小三角图标的方法,通过简单的代码实现网页上的装饰元素,加载速度快,适用于各种网页设计场景。
1167

被折叠的 条评论
为什么被折叠?



