:before与:after伪类的应用
1.小三角样式
.tip{
position:relative;
display:inline-block;
width:100px;
margin:100px;
padding:30px 20px;
color:#fff;
border:1px solid #666;
border-radius:5px;
background-color:rgba(0,153,51,1);
}
.tip:before{
content:'';
position:absolute;
top:15px;
left:-20px;
border:10px solid #666;
border-color:transparent #666 transparent transparent;
}
.tip:after{
content:'';
position:absolute;
top:15px;
left:-18px;
border:10px solid rgba(0,153,51,1);
border-color:transparent rgba(0,153,51,1) transparent transparent;
}
2.取消浮动
.float{
border:1px solid #000;
zoom:1; /*解决ie6,ie7浮动问题*/
}
.float:after{
content:'';
display:block;
width:0;
height:0;
clear:both;
}
.fl{
float:left;
width:300px;
height:200px;
color:#fff;
background:rgba(204,51,0,1);
}
.fr{
float:right;
width:300px;
height:200px;
color:#fff;
background:rgba(0,102,102,1);
}
1.:after消除浮动,父元素需加zoom:1,建议使用,
2.在父元素的末尾加一个孩子,<div style="clear:both"></div>
3.在父元素中增加overflow:hidden; 不能和position配合使用,因为超出的尺寸的会被隐藏
4.在父元素中增加overflow:auto;前提是必须定义width 或 zoom:1,并且不能定义height
5.父元素一起浮动,不推荐使用
6.给父元素增加display:table,不建议使用
3.单选或复选
.simple{
width:100px;
height:20px;
border:1px solid #000;
line-height:20px;
padding:10px;
display:inline-block;
}
.simple input{
display:none;
}
.simple label:before{
content:'';
display:inline-block;
width:15px;
height:15px;
vertical-align:-2px;
margin-right:5px;
border:1px solid #000;
}
.simple input:checked + label:before{
content:'';
display:inline-block;
width:15px;
height:15px;
background:rgba(255,51,0,1);
vertical-align:-2px;
margin-right:5px;
border:1px solid #000;
}
.middle{
display:inline-block;
position:relative;
overflow:hidden;
}
.middle input{
display:none;
}
.middle label{
padding:10px;
display:inline-block;
border:1px solid #000;
}
.middle input:checked + label{
border:rgba(0,255,255,1) 1px solid ;
}
.middle input:checked + label:after{
content:"";
position:absolute;
bottom:0px;
right:0px;
width:10px;
height:10px;
border-radius:10px 0 0 0;
display:inline-block;
background:#F03;
color:#fff;
}
.hight{
display:inline-block;
position:relative;
}
.hight input{
display:none;
}
.hight input + label:before{
content:'';
display:inline-block;
width:48px;
height: 24px;
margin-right:10px;
vertical-align:-6px;
background:#e0e0e0;
position:relative;
border-radius:24px;
transition:background 0.3s;
}
.hight input + label:after{
content:'';
display:inline-block;
width:20px;
height:20px;
border-radius:20px;
background:#fff;
position:absolute;
top:2px;
left:2px;
transition:left 0.32s;
}
.hight input:checked + label:before{
background:rgba(153,0,153,1);
}
.hight input:checked+label:after{
left:26px;
}
.diff{
display:inline-block;
position:relative;
}
.diff label{
width:auto;
height:48px;
}
.diff label input{
display:none;
}
.diff label input + i{
content:'';
position:relative;
width:48px;
height:24px;
border-radius:24px;
background:#e0e0e0;
display:inline-block;
transition:background 0.3s;
}
.diff label input + i:after{
content:"";
position:absolute;
top:2px;
left:2px;
display:inline-block;
background:#fff;
width:20px;
height:20px;
border-radius:20px;
transition:left 0.3s;
}
.diff label input:checked + i{
background:#0F0;
}
.diff label input:checked + i:after{
left:26px;
}
:before与:after伪类的应用的更多相关文章
- 谈谈一些有趣的CSS题目(十)-- 结构性伪类选择器
开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...
- CSS3 nth 伪类选择器
考察下面的 HTML 代码片段: <div> <section>section 1</section> <section>section 2</s ...
- CSS权威指南之css声明,伪类,文本处理--(简要笔记一)
1.css层叠的含义 后面的会覆盖前面的样式 2.每个元素生成一个框,也称盒. 3.替换元素和非替换元素. img如果不指定src的外部路径,该元素就没有意义.他由文档本身之外的一个图像文件来替换 ...
- CSS-用伪类制作小箭头(轮播图的左右切换btn)
先上学习地址:http://www.htmleaf.com/Demo/201610234136.html 作者对轮播图左右按钮的处理方法一改往常,不是简单地用btn.prev+btn.next的图片代 ...
- 伪类before和after
以你添加的元素为基础!在他的里面!也就是他的内容的前面或者后面添加东西! 如果原来的元素没有内容会出现什么情况?(伪类的宽和高和元素的相等)
- 解密jQuery内核 Sizzle引擎筛选器 - 位置伪类(一)
本章开始分析过滤器,根据API的顺序来 主要涉及的知识点 jQuery的组成 pushStack方法的作用 sizzle伪类选择器 首页我们知道jQuery对象是一个数组对象 内部结构 jQuery的 ...
- 利用伪类:before&&:after实现图标库图标
一.实现如下效果 二.代码实现思路 图案一源码 <!DOCTYPE html> <html> <head> <meta charset="utf-8 ...
- CSS笔记之伪类与伪元素
伪类分为两种:UI伪类 与 结构化伪类 UI伪类:a:link{} a:hover{} a:active{} a:visited{} input[type='text']:focus{} ...
- W3School-CSS 伪类 (Pseudo-classes) 实例
CSS 伪类 (Pseudo-classes) 实例 CSS 实例 CSS 背景实例 CSS 文本实例 CSS 字体(font)实例 CSS 边框(border)实例 CSS 外边距 (margin) ...
- <a>链接的四个伪类顺序
<a>元素的作用是可以创建一个链接,链接对应4个状态:未访问,已访问,鼠标悬停,鼠标点击瞬间. 为了给链接的4个状态应用样式,引入伪类的概念. 什么是伪类呢?简单点说,就是你没定义这个类, ...
随机推荐
- [Mugeda HTML5技术教程之8]添加行为
上一节我们已经在新建的作品中添加了元素和动画,如果我们想要作品能够和用户互动,就需要给元素添加动作行为.在舞台上选中一个要添加动作的元素,在属性栏的动作下拉列表中选择一个动作.可选类别有链接.表单.行 ...
- PHP内置Web Server探究(二)自定义PHP控制台输出console函数
我们在开发APP的服务器端,当和APP进行联调时通常需要实时跟踪URL请求和参数的接收情况. 但PHP并没有像Python或Java专有的控制台输出函数,Python的print()和Java的Sys ...
- PYTHON简介及安装
Python简介 Python是一种广泛使用的高层次,通用,解释,动态编程语言.它的设计理念强调代码的可读性,它的语法允许程序员表达更少的代码的概念比将在可能语言如C ++或Java.该语言提供旨在使 ...
- TextField控件详解2
//初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, ...
- Activiti 5.18 流程Model 转成 流程BPMN文件
直接上代码吧 byte[] bpmnBytes = null; String filename = null; JsonNode editorNode = new ObjectMapper().rea ...
- NGINX的CORS--跨域访问配置
阻止交叉源访问问题. 网上可搜N多,解决办法都差不多,其中一种: add_header Access-Control-Allow-Origin http://xxxx:port; add_header ...
- LeetCode_Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...
- 各类XML parser的比较
基于以上的比较 再为公司的项目选择解析器的时候,我选择Xerces.准备把Qt自带的XML库给去掉. references: http://stackoverflow.com/questions/17 ...
- UBI(unsorted block image )块管理
一.介绍 ubi是unsorted block images的缩写,是由IBM开发设计的,它与ubifs有不同的含义,ubifs是一种文件系统(nokia开发的):而ubi是一种块管理工具,工作在mt ...
- [WPF] 将普通的Library工程,改造成WPF Custom Control 的Library
1. 添加References PresentationCore PresentationFramework System.Xaml WindowsBase2. 修改AssemblyInfo.xsus ...