其他分享
首页 > 其他分享> > 小三角形

小三角形

作者:互联网

看效果

思路

1.使用css超伪类。子绝父相(给div设置相对定位,给div的伪类设置绝对定位)

2.宽高设置为0,设置边框宽,边框颜色设置为透明

代码

1.html

		<div class="sjx">

		</div>

2.css

			* {
				margin: 0px;
				padding: 0px;
				list-style: none;
				text-decoration: none;
			}

			body {
				background-color: skyblue;
			}

			.sjx {
				width: 100px;
				height: 44px;
				background: #FFF;
				position: relative;
				border-radius: 10px;
				margin: 100px auto;
			}

			.sjx::after {
				content: '';
				display: block;
				width: 0;
				height: 0;
				overflow: hidden;
				font-size: 0;
				line-height: 0;
				border: 14px;/*控制三角形的大小*/
				border-style: dashed dashed solid dashed;
				border-color: transparent transparent #fff transparent;
				position: absolute;
				left: 6px;/*控制三角形的位置*/
				top: -27px;
			}

标签:dashed,height,设置,三角形,border,transparent
来源: https://www.cnblogs.com/mywifeisMsHu/p/15331506.html