css实现自定义按钮的样式实际上很早就有了,只是会用的人不是很多,里面涉及到了最基础的css写法,在火狐中按钮还是会显示出来,这时需要将i标签的背景设置为白色,同时z-index设置比input高一些,这样才可以把按钮盖住,同时注意:background-color放在background后才起作用

/*自定义按钮 */
.invoice-class-type{
position:relative;
display:inline-block;
width:120px;
height:30px;
line-height:30px;
text-align: center;
}
.invoice-class-type>input[type="radio"]{
position:absolute;
display:block;
height:1px;
widht:1px;
left:0;
top:0;
}
.invoice-class-type>input[type="radio"]+i{
display:block;
position:absolute;
left:0;
top:0;
z-index:10;
line-height:30px;
width:120px;
height:30px;
border:1px solid #888;
border-radius:2px;
cursor:pointer;
background-color:#fff;
}
.invoice-class-type>input[type="radio"]:checked+i{
border-color:#f30026;
background:url(../images/modify-img/red_right.png) no-repeat right bottom;
background-color:#fff;
}
/*结束 自定义按钮*/

  

  

效果图:

又例如:单选按钮时只需要注意name属性就行

/*checkbox*/
.s-checkbox{
position:relative;
display: inline-block;
}
.shopping_table_check1{
position:relative;
}
.shopping_table_check1>span:before{
margin-top:20px;
}
input[type="radio"].custom-checkbox,
input[type="checkbox"].custom-checkbox{
position: absolute;
z-index: -100;
height: 1px;
width: 1px;
top:0;
left:0;
}
input[type="radio"].custom-checkbox+span:before,
input[type="checkbox"].custom-checkbox+span:before{
display: inline-block;
content: "\a0";
width: 18px;
height: 18px;
line-height: 18px;
font-weight:800;
text-align: center;
box-shadow: 0 1px 2px rgba(0,0,0,.05);
border:1px solid #f30026;
background-color:#fff;
color:#fff;
}
input[type="radio"].custom-checkbox:checked+span:before,
input[type="checkbox"].custom-checkbox:checked+span:before{
box-shadow:none;
background-color:#f30026;
content: "√";
}
/*结束 checkbox*/

效果图如下:

  

 结合css3写炫酷按钮

CSS

.animate-checkbox{
position: relative;
display: inline-block;
width:60px;
height:30px;
border-radius: 15px;
background-color:#fff;
box-shadow: 1px 0 3px #333;
margin-top: 30px;
cursor: pointer;
}
.animate-checkbox input{
position: absolute;
top:0;
left:0;
height:1px;
width:1px;
z-index: 1;
}
.animate-checkbox i{
position: absolute;
left:0;
top:0;
background-color: #428bca;
width:30px;
height: 30px;
border-radius: 15px;
z-index: 2;
transition: width linear .2s;
}
.animate-checkbox i:before{
display: block;
position: absolute;
content:" ";
left:0;
top:0;
width:30px;
height: 30px;
border-radius: 100%;
background-color:#f30026;
transition: left linear .2s;
}
.animate-checkbox input[type="checkbox"]:checked+i{
width:60px;
transition: width linear .2s;
}
.animate-checkbox input[type="checkbox"]:checked+i:before{
left:30px;
transition: left linear .2s;
}

DOM  结果

<label class="animate-checkbox">
<input type="checkbox" name="">
<i></i>
</label>

效果图

没选中

选中  

  

 

css笔记——css 实现自定义按钮的更多相关文章

  1. HTML+CSS笔记 CSS笔记集合

    HTML+CSS笔记 表格,超链接,图片,表单 涉及内容:表格,超链接,图片,表单 HTML+CSS笔记 CSS入门 涉及内容:简介,优势,语法说明,代码注释,CSS样式位置,不同样式优先级,选择器, ...

  2. HTML+CSS笔记 CSS中级 一些小技巧

    水平居中 行内元素的水平居中 </a></li> <li><a href="#">2</a></li> &l ...

  3. HTML+CSS笔记 CSS中级 颜色&长度值

    颜色值 在网页中的颜色设置是非常重要,有字体颜色(color).背景颜色(background-color).边框颜色(border)等,设置颜色的方法也有很多种: 1.英文命令颜色 语法: p{co ...

  4. HTML+CSS笔记 CSS中级 缩写入门

    盒子模型代码简写 回忆盒模型时外边距(margin).内边距(padding)和边框(border)设置上下左右四个方向的边距是按照顺时针方向设置的:上右下左. 语法: margin:10px 15p ...

  5. HTML+CSS笔记 CSS进阶再续

    CSS的布局模型 清楚了CSS 盒模型的基本概念. 盒模型类型, 我们就可以深入探讨网页布局的基本模型了.布局模型与盒模型一样都是 CSS 最基本. 最核心的概念. 但布局模型是建立在盒模型基础之上, ...

  6. HTML+CSS笔记 CSS进阶续集

    元素分类 在CSS中,html中的标签元素大体被分为三种不同的类型:块状元素.内联元素(又叫行内元素)和内联块状元素. 常用的块状元素有: <div>.<p>.<h1&g ...

  7. HTML+CSS笔记 CSS进阶

    文字排版 字体 我们可以使用css样式为网页中的文字设置字体.字号.颜色等样式属性. 语法: body{font-family:"宋体";} 这里注意不要设置不常用的字体,因为如果 ...

  8. HTML+CSS笔记 CSS入门续集

    继承 CSS的某些样式是具有继承性的,那么什么是继承呢?继承是一种规则,它允许样式不仅应用于某个特定html标签元素,而且应用于其后代(标签). 语法: p{color:red;} <p> ...

  9. HTML+CSS笔记 CSS入门

    简介: </span>年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的<span>脚本解释程序</span>,作为ABC语言的一种继承. & ...

随机推荐

  1. 使用DataSet Datatable 更新数据库的三种方式

    1:自动生成命令的条件 CommandBuilder 方法a)动态指定 SelectCommand 属性b)利用 CommandBuilder 对象自动生成 DataAdapter 的 DeleteC ...

  2. Java和C#在面向对象上语法的区别

    做了几年了开发一直没有总结什么,回到了家乡的小城做了一名培训班的教员,教授软件开发的知识.细小的知识从头细细嚼来,别有一番滋味.或是以前遗漏的太多,或是确实没有系统的学习过,教学生的过程中自己也对教材 ...

  3. delphi Caption 垂直显示标签文本

    //垂直显示标签文本 Label1.Caption:='垂'+#13+'直'+#13+'显'+#13+'示';//使用相同的方法,我们也可以制作垂直显示的提示(Hint):button1.Hint:= ...

  4. 【android】在eclipse中查看genymotion模拟器的sd卡文件夹

    假设用google自带模拟器或者真机调试时,sd卡文件夹是在/mnt/sdcard.这个相信大家都知道. 但是今天用genymotion调试时.发现根本打不开/mnt/sdcard这个文件夹,当时也没 ...

  5. SDWebImage内存性能优化

    // 清除已过期图片 [[SDImageCache sharedImageCache] cleanDisk]; // 设置最多缓存7天时间 [[SDImageCache sharedImageCach ...

  6. Quart 2D 绘制图形简单总结

    0  CGContextRef context = UIGraphicsGetCurrentContext(); 设置上下文 1 CGContextMoveToPoint 开始画线 2 CGConte ...

  7. android151 笔记 3

    34. 对android虚拟机的理解,包括内存管理机制垃圾回收机制. 虚拟机很小,空间很小,谈谈移动设备的虚拟机的大小限制 16M , 谈谈加载图片的时候怎么处理大图片的,压缩. 垃圾回收,没有引用的 ...

  8. android141 360 安装软件管理java代码

    AppManagerActivity package com.itheima52.mobilesafe.activity; import android.app.Activity; import an ...

  9. A Simple Actions Recognition System

    1. Problem Definition There's no doubt that researches and applications on the foundation of videos ...

  10. MySQL_update同一张表

    update tb1 inner join(select type, count(*) as cntfrom tb1 group by type)as der using(type)set tb1.c ...