HTML demo
效果
点击:
释放:
代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
.box{
width: 100px;
height: 100px;
margin: 10px;
background-color: #dfdfdf;
position: relative;
}
.box:before{
width: 0;
height: 0;
/* 设置透明度的时候不要设置边框颜色 */
border-bottom: 50px solid transparent;
border-top: 50px solid transparent;
border-left: #269ABC 50px solid ;
display: block;
position: absolute;
left: 100px;
/* 必须要 */
content: " ";
display: none;
}
.box:hover:before{
display: block;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>