自学篇之-----纯css做的漂亮的单选框复选框样式

<!DOCTYPE html>
<html>
<head>
<title>checkbook</title>
<meta charset="utf-8" />
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>

<style type="text/css">

[id^="checkbox-"] + label {
 background-color: #FFF;
 padding: 11px 9px;
 border-radius: 7px;
 display: inline-block;
 position: relative;
 margin-right: 30px;
 background: #F7836D;
 width: 88px;
 height: 13px;
 box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1), 0 0 10px rgba(245, 146, 146, 0.4);
}

[id^="checkbox-"] + label:before {
 content: ‘ ‘;
 position: absolute;
 background: #FFF;
 top: 0px;
 z-index: 99999;
 left: 0px;
 width: 24px;
 color: #FFF;
 height: 35px;
 border-radius: 7px;
 box-shadow: 0 0 1px rgba(0,0,0,0.6);
}

[id^="checkbox-"] + label:after {
 content: ‘禁止‘;
 position: absolute;
 top: 7px;
 left: 37px;
 font-size: 1.2em;
 color: white;
 font-weight: bold;
 left: 8px;
 padding: 5px;
 top: 4px;
 border-radius: 100px;
}

[id^="checkbox-"]:checked + label {
 background: #67A5DF;
 box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1), 0 0 10px rgba(146, 196, 245, 0.4);
}

[id^="checkbox-"]:checked + label:after {
 content: ‘允许‘;
 left: 6px;
}

[id^="checkbox-"]:checked + label:before {
 content: ‘ ‘;
 position: absolute;
 z-index: 99999;
 left: 82px;
}

[id^="checkbox-"] + label:after {
 left: 35px; 
}

.radio +label{
position: relative;
display: inline-block;
z-index: 999;
width: 12px;
height: 25px;
padding: 3px 29px;
}

.radio+label:before{
 content:"";
 color:#fff; 
 width: 20px;
 height: 20px;
 background: #777980;
 border-radius: 15px;
 position: absolute;
 top: 4px;
 left: 4px;
 display:block;
 box-shadow: 0px 0px 3px #A19797;
}
.radio:checked+label:before{
content:"";
background: #1caf9a;
}
.radio+label:after{
 content: attr(title);
 width: 8px;
 height: 8px;
 display:block;
 border: 3px solid #F7F9F9;
position: absolute;
top: 7px;
left: 7px;
border-radius: 7px;
background: #777980;
box-shadow: 0px 0px 3px #F2EBEB;
}
.radio:checked+label:after{
background: #1caf9a;
}
</style>
</head>
<body>
<p>利用复选框做开关</p>
<input type="checkbox" id="checkbox-2"  hidden /><label for="checkbox-2"></label>

<div style="margin: 30px;">
<p>问:您是否觉得您是最好的?</p>
<input type="radio" class="radio" name="n" id="check-1" hidden><label for="check-1">是</label>

<input type="radio" class="radio" name="n" id="check-2" hidden><label for="check-2" title="">否</label>

</div>

</body>  
</html>

时间: 2024-08-28 06:17:50

自学篇之-----纯css做的漂亮的单选框复选框样式的相关文章

CSS定义Radio单选项和Checkbox复选框样式有效代码

我们都知道一般情况利用css来定义Radio单选项和Checkbox复选框样式是无效的,下面我来给大家介绍利用CSS定义Radio单选项和Checkbox复选框样式,有需要了解的朋友可参考. 完全使用css来实例 复制代码 代码如下: <style type=”text/css”> form#form1 {font:12px tahoma,sans-serif} input[type="checkbox"] {visibility:hidden;width:0;height

纯css修改单选、复选按钮样式

只支持IE9及以上 html <label><input class="radio" type="radio" name="radio1"/><span class="radio-style"></span>10</label> <label><input class="radio" type="checkbox&quo

[CSS]复选框单选框与文字对齐问题的研究与解决.

前言:今天碰到的这个问题, 恰好找到一个很好的博文, 在这里转载过来 学习下. 原文地址:复选框单选框与文字对齐问题的研究与解决. 目前中文网站上面的文字,就我的个人感觉而言,绝大多数网站的主流文字大小为12px,因为在目前高分辨率显示器屏幕下,11px的汉字,其像素点开始不规整,文字不如12px来的显示良好.12px大小的文字就是主流也是底线.然而12px的文字与单选框和复选框是不对齐的.例如下面这张雅虎中国首页在火狐浏览器下的截图: 雅虎中国首页单选框复选框与文字不对齐 这里,不是说,雅虎中

不用系统自带的复选框,单选按钮,选择框的样式,该怎么做

这里我主要针对pc端而言,移动端由于各个牌子的移动设备都有自己定义的复选框,单选按钮和选择框样式,这里不做讨论. pc端的默认样式大家都见过,这里直接上效果图 这是我简单做的两个自定义的复选框,单选按钮.以复选框为例,将复选框用一个div包裹起来,然后将复选框的透明度设置为0,下面来看看这个效果的代码 <style> .checks_icon{border: 1px solid red;border: 1px solid #ccc;padding: 0;height: 12px; width:

自学篇之--js 提取复选框和单选框的值 和纯css的3D按钮

<html> <head> <meta charset="utf-8" content="text/htnl"> <title>button</title> <style type="text/css"> a.button{ position:relative; width: 80px; height: 50px; background-color: red; display

纯css做三角形形状

1 /* create an arrow that points up */ 2 div.arrow-up { 3 width:0px; 4 height:0px; 5 border-left:5px solid transparent; /* left arrow slant */ 6 border-right:5px solid transparent; /* right arrow slant */ 7 border-bottom:5px solid #2f2f2f; /* bottom,

一款纯css实现的漂亮导航

今天给大家分享一款纯css实现的漂亮导航.之前为大家分享过jquery实现的个人中心导航菜单,今天这款也是适合放在个人中心.还带来图标,效果不错.一起看下效果图: 在线预览   源码下载 实现的代码. html代码: <div class="l-main"> <div class="menu"> <header class="menu__header"> <h1 class="menu__hea

纯css做幻灯片效果

css3里面有一个@keyframes动画功能. w3c上面的例子: 可以使用它来做一个幻灯片效果. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>纯CSS做幻灯片</title> </head> <style> @keyframes slide { 0% { backgroun

纯CSS设置Checkbox复选框控件的样式

下面是纯CSS设置Checkbox复选框控件的五种简单样式,有兴趣的可以进行改动将其变成自己想要的样式. 首先,需要添加一段CSS隐藏所有的Checkbox复选框,下面我们会改变它的外观.要做到点需要添加一段代码到你的CSS文件中. 隐藏掉所有的Checkbox复选框后,我们需要添加一个label HTML元素,我们都知道,当点击的有for属性的label标签时,对应的Checkbox复选框会被选中.这意味着,我们可以通过label的点击事件来处理我们的Checkbox复选框. 样式一 此复选框