样式效果:
代码实现:(纯css,伪类实现)
html
<div class="item" v-for="i in 3" :key="i" :class="i===1?'selected':''">{{ i }}</div>
<style>
.item {
padding: 6px 12px;
background-color: #ffffff;
border: 1px solid #ddd;
width: 40px;
margin: 10px;
text-align: center;
display: inline-block;
position: relative; // 必须有
}
.selected {
border-color: #14BCF5;
&:before { // 三角形背景
content: "";
position: absolute;
right: 0;
bottom: 0;
border: 10px solid #14BCF5;
border-top-color: transparent;
border-left-color: transparent;
}
&:after { // 对钩
content: "";
width: 6px;
height: 8px;
position: absolute;
right: 3px;
bottom: 3px;
border: 1px solid #fff;
border-top-color: transparent;
border-left-color: transparent;
transform: rotate(45deg);
}
}
</style>