使用css实现多选select选中效果
HTML
2023-05-25 16:13:56
随着互联网的普及,人们对于美观需求也变得越来越苛刻。而对于浏览器提供的默认选中效果显然已经不足以满足用户对于个性化的需求。
本文分享一个基于css的选中效果,如图:
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="anniu selct_active" >按钮1</div>
<div class="anniu selct_active" >按钮2</div>
<div class="anniu selct_active" >按钮</div>
<div class="anniu selct_active" >按钮</div>
<style>
.anniu{
width: 100px;
height: 40px;
line-height: 40px;
text-align: center;
float: left;
margin: 10px;
}
.selct_active{
position: relative;
border: 1px solid #00aaff;
background: rgba(0, 170, 255, .2);
border-radius: 5px;
}
.selct_active::before{
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 20px;
height: 20px;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAACe9JREFUeF7t3X2LJVcRx/Fq88aCkhCJaEJ0E40a3TwgEiEIShAkqyCiIIIhhMQ8R93c7iUPGBQl4jtLyY2ZzO7s3Olzqqu7z6n63n/3VM+pX9WHmd3ZuTMILxIggZMJDGRDAiRwOgGAsB0kcEUCAGE9SAAg7AAJ2BLgM4gtN6qSJACQJIOmTVsCALHlRlWSBACSZNC0aUsAILbcqEqSAECSDJo2bQkAxJYbVUkSAEiSQdOmLQGA2HKjKkkCAEkyaNq0JQAQW25UJUkAIEkGTZu2BABiy42qJAkAJMmgadOWAEBsuVGVJAGAJBk0bdoSAIgtN6qSJACQJIOmTVsCALHlRlWSBACSZNC0aUsAILbcqEqSAECSDJo2bQkAxJYbVUkSAEiSQdOmLQGA2HKjKkkCAEkyaNq0JQAQW25UJUkAIEkGTZu2BABiy42qJAkAJMmgadOWAEBsuVGVJAGAJBk0bdoSAIgtN6qSJACQJIOmTVsCALHlRlWSBACSZNC0aUsAILbcqEqSAECSDJo2bQkAxJYbVUkSAEiSQdOmLQGA2HKjKkkCAEkyaN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WfAxCPdFvC4Y1k0pui8thnXwr5/Jf1h2SQDzxi3+IZAFmacos4vJEcf6+GB45Rvy4iHy2NfMt6gCxJu2Uc3kiW5HSsnfRrovL3pY/Zuh4g1sR7wNEKklEfFJGPrVHvWQcQS/o94dgbyaRfFZV/WGJuoQYgtVPoEcdeSEZ9QET+WRtxS+cBUjONnnFsjWTS+0XlXzXxtngWIKVTiYBjKySj3ici/y6NtuVzACmZTiQcayOZ9Cui8klJrD2cAcjclCLiWAvJqF8Wkf/MRdrTnwPkqmlFxuGNZNJ7ReW/PS1/yV0BciqlDDi8kNzUe+WeeDiO8QDkMiCZcCxFEhgHQMBxZwK1P5kY6F+rTn0hwWeQ25PJ+Jnj4maUIpn0G6LyYcnX8T2fAcjZ9MBxvsdzSBp9g4U1IALkmCo47t6tU0h2fq/cNRBc9UyAgOP0flxEMuqzIvLi1ku658fLDQQc87t3hmTSn4vK7+YLYp3ICwQc5Zu8/2+oKr+r88mcQMDhvEZxH5cPCDjibvMKneUCAo4VVij2I/MAAUfsTV6puxxAwLHS+sR/bHwg4Ii/xSt2GBsIOFZcnRyPjgsEHDk2eOUuYwIBx8prk+fx8YCAI8/2btBpLCDg2GBlcn2IOEDAkWtzN+r2f8fa89ffSL+xAAAAAElFTkSuQmCC') no-repeat center;
background-size: 100% 100%;
z-index: -1;
}
</style>
</body>
</html>
该选中效果主要是使用的position定位来实现选中样式,主要关键点为position的relative和absolute及before
六月初字帖坊小程序
你想要的字帖模板及工具,这里都有!
877篇文章
1122人已阅读