Input标签的美化,借用lable

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin:0;padding:0;list-style: none;
}
li{
position: relative;
height:50px;
}
input{
display: none;
}
label{
display: inline-block;
position: relative;
}
label::before{
display: inline-block;
content: "注册公司";
height: 40px;
line-height: 40px;
padding:0 10px;
position: relative;
top:0;
border: 1px solid #000;
}
label>i::before{
content: "";
display: none;
position: absolute;
bottom: 0;
right: 0;
width:13px;
height:13px;
background: url(images/xiajiao.png) no-repeat ;
z-index: 999;
}
input[type="radio"]:checked+label::before{
border: 1px red solid;
}
input[type="radio"]:checked+label>i::before{
display: block;
}
</style>
</head>
<body>
<ul>
<li>
<input type="radio" name="1" id="ds"/>
<label for="ds"><i></i></label>
<input type="radio" name="1" id="ds1"/>
<label for="ds1"></label>
</li>
</ul>
</body>
</html>

 

通过添加label标签,隐藏input,从而给label加样式,达到美化input框的效果。

其中简单的样式添加,通过:before完成。

posted @ 2017-10-18 13:29  circleline  阅读(611)  评论(0编辑  收藏  举报