涉及到伪类操作,一直都是网上找例子改吧改吧,今天优化项目,顺便记录下实现的效果。
如何实现,也简单。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.btn-wrap{
position: relative;
}
.btn {
position: relative;
border: 1px solid #fa4943;
display: inline-block;
text-align: center;
cursor: pointer;
background-image: none;
white-space: nowrap;
line-height: 1.5;
padding: 5px 15px 6px;
font-size: 12px;
border-radius: 4px;
color: #515a6e;
background-color: #fff;
}
.btn-icon{
position: absolute;
top: 0;
right: 0;
font-size: 12px;
color: #ffffff;
font-weight: 700;
z-index: 111;
}
.btn-icon:before {
content: "√";
margin-right: 2px;
}
.btn-select::before {
content: "";
width: 0px;
height: 0px;
border-left: 18px solid transparent;
border-right: 18px solid #ed4014;
border-bottom: 18px solid transparent;
position: absolute;
top: 0px;
right: 0px;
}
</style>
</head>
<body>
<div class="btn-wrap">
<button class="btn">1000
<!--可以直接使用字体图标 btn-icon 为了演示-->
<span class="btn-icon"></span>
<span class="btn-select"></span>
</button>
</div>
</body>
</html>