纯css改变radio样式
2015-07-18 19:53
716 查看
具体的就是用上css3中的内容,和position,具体的可以参考一下代码,
详情可以参考:http://codepen.io/jcpplus/pen/ukvps
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.smart-form :after, .smart-form :before {
margin: 0;
padding: 0;
//@include box-sizing(content-box);
}
.smart-form .radio,
{
position: relative;
display: block;
font-weight: 400;
}
.smart-form .radio {
margin-bottom: 4px;
padding-left: 25px;
line-height: 25px;
color: #0c4757;
cursor: pointer;
font-size: 13px;
}
/*add*/
.smart-form .radio input {
position: absolute;
left: -9999px;
}
.smart-form .radio i {
position: absolute;
top: 6px;
left: 0;
display: block;
width: 15px;
height: 15px;
outline: 0;
border-width: 1px;
border-style: solid;
background: #9cd9e8;
}
.smart-form .radio i {
border-radius: 50%;
}
.smart-form .radio i,
{
border-color: #47A8C0;
transition: border-color .3s;
-webkit-transition: border-color .3s;
}
.smart-form .radio input:checked+i, {
border-color: #47A8C0;
}
.smart-form .radio input+i:after {
position: absolute;
opacity: 0;
transition: opacity .1s;
-webkit-transition: opacity .1s;
}
.smart-form .radio input+i:after {
content: '';
top: 3px;
left: 3px;
width: 9px;
height: 9px;
border-radius: 50%;
}
.smart-form .radio input+i:after {
background-color: #47A8C0;
}
.smart-form .radio input:checked+i:after {
opacity: 1;
}
</style>
</head>
<body>
<form action="" class="smart-form">
<fieldset>
<section>
<label class="label">Columned radios</label>
<div class="row">
<div class="col col-4">
<label class="radio">
<input type="radio" name="radio" checked="checked">
<i></i>Alexandra</label>
<label class="radio">
<input type="radio" name="radio">
<i></i>Alice</label>
<label class="radio">
<input type="radio" name="radio">
<i></i>Anastasia</label>
<input type="radio" name="radio">
<i></i>Anastasia
</div>
</div>
</section>
</fieldset>
</form>
</body>
</html>
详情可以参考:http://codepen.io/jcpplus/pen/ukvps
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.smart-form :after, .smart-form :before {
margin: 0;
padding: 0;
//@include box-sizing(content-box);
}
.smart-form .radio,
{
position: relative;
display: block;
font-weight: 400;
}
.smart-form .radio {
margin-bottom: 4px;
padding-left: 25px;
line-height: 25px;
color: #0c4757;
cursor: pointer;
font-size: 13px;
}
/*add*/
.smart-form .radio input {
position: absolute;
left: -9999px;
}
.smart-form .radio i {
position: absolute;
top: 6px;
left: 0;
display: block;
width: 15px;
height: 15px;
outline: 0;
border-width: 1px;
border-style: solid;
background: #9cd9e8;
}
.smart-form .radio i {
border-radius: 50%;
}
.smart-form .radio i,
{
border-color: #47A8C0;
transition: border-color .3s;
-webkit-transition: border-color .3s;
}
.smart-form .radio input:checked+i, {
border-color: #47A8C0;
}
.smart-form .radio input+i:after {
position: absolute;
opacity: 0;
transition: opacity .1s;
-webkit-transition: opacity .1s;
}
.smart-form .radio input+i:after {
content: '';
top: 3px;
left: 3px;
width: 9px;
height: 9px;
border-radius: 50%;
}
.smart-form .radio input+i:after {
background-color: #47A8C0;
}
.smart-form .radio input:checked+i:after {
opacity: 1;
}
</style>
</head>
<body>
<form action="" class="smart-form">
<fieldset>
<section>
<label class="label">Columned radios</label>
<div class="row">
<div class="col col-4">
<label class="radio">
<input type="radio" name="radio" checked="checked">
<i></i>Alexandra</label>
<label class="radio">
<input type="radio" name="radio">
<i></i>Alice</label>
<label class="radio">
<input type="radio" name="radio">
<i></i>Anastasia</label>
<input type="radio" name="radio">
<i></i>Anastasia
</div>
</div>
</section>
</fieldset>
</form>
</body>
</html>
相关文章推荐
- 纯css画三角形/梯形(兼容ie6)
- 一波CSS+Div实用技巧小结
- 深入理解CSS中选择器的逻辑处理
- css中设置图片的显示与隐藏
- CSS 扩展技术
- 详细解读CSS中的伪类after
- 详解CSS3中border-image的使用
- CSS3中颜色线性渐变实战
- 使用CSS3来绘制一个月食图案
- CSS元素居中布局的简单方法
- @import url("layout.css"); css 引入 css ------@charset "utf-8";
- 图片随机小角度堆叠效果,可用于相册缩略图叠加样式【长宽最优化】
- CSS之BFC
- 举例详解CSS的z-index属性的使用
- CSS 收集
- sublime text 侧边栏样式修改
- CSS+DIV把八个层并排显示!!!
- css3属性(一)
- CSS3设计边框忽隐忽现功能
- scss学习笔记