修改input复选框的样式

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.test {
position: relative;
}
input {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 1;
opacity: 0;
}
span {
display: inline-block;
position: relative;
width: 30px;
height: 30px;
border: 1px solid red;
}
input:checked~span {
background: url(test/img-upload-delete/img/xin1.jpg) no-repeat;
background-size: 100% 100%;
border: none;
}
</style>
</head>
<body>
<p class="test">
<input type="checkbox" name="" id="" value="" />
<span></span>
</p>
</body>
</html>

// 如果复选框被清楚默认样式后在某些地方又想使用默认样式时,就加上-webkit-appearance: checkbox;就可以返回默认样式

input{-webkit-appearance: checkbox;}

发布了21 篇原创文章 · 获赞 3 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_40039641/article/details/80921734
今日推荐