CSS的一些常用样式,如背景、文字、文本、表格、列表等,以及一些常用的场景,如居中对齐、溢出、隐藏元素等。01、常用样式 1.1、background背景 设置元素背景的样式 background,更
顺晟科技
2021-07-31 07:31:39
332
在网页中,你在很多地方都能看到倒三角,比如tooltips,下拉菜单等。本文介绍三种css3倒三角样式的实现方式。
1.BASE64编码 图片
假如你已经有了三角形的图片,并且减少HTTP请求,那么将这个图片转换成一个BASE64字符串是更好的解决方案。
有用的工具
http://webcodertools.com/imagetobase64converter
http://image2base64.wemakesites.net/
2.CSS3 边框
<html>
<title>倒三角演示代码1</title>
<head>
<style type="text/css">
.triangleDiv{
border-color: #57af1a #fff #fff #fff;
border-style: solid;
border-width: 100px 60px 0 60px;
height: 0;
width: 0;
}
</style>
</head>
<body>
<div class='triangleDiv'></div>
</body>
</html>
3.Unicode字符
<html>
<title>倒三角演示代码2</title>
<head>
<style type="text/css">
.triangleDiv{
font-size: 18px;
color: #f7931d;
text-shadow: 0 1px 1px rgb(99, 95, 92);
}
</style>
</head>
<body>
<span class='triangleDiv'>▼</span>
</body>
</html>
4.CSS3 旋转正方形
<html>
<title>倒三角演示代码3</title>
<head>
<style type="text/css">
.parentDiv {
height: 14px;
overflow: hidden;
}
.triangleDiv {
position: relative;
height: 20px;
width: 12px;
top: -12px;
left: 7px;
background: #0c0c0c;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
</style>
</head>
<body>
<div>
<div></div>
</div>
</body>
</html>
以上三种css3倒三角样式的实现方式供大家参考,如果大家还有更好的CSS3倒三角样式的实现方式,欢迎留言讨论。
09
2022-11
22
2022-10
19
2022-10
19
2022-10
19
2022-10
19
2022-10