CSS3:伪对象选择器
来源:互联网 发布:有了源码怎么架设游戏 编辑:程序博客网 时间:2024/06/08 18:58
1. :before 选择器在被选元素的内容前面插入内容。
:after 选择器在被选元素的内容后面插入内容。
注意:before 和after必须和content结合使用,即使没有内容插入也要写content=' '
示例代码:
#poem:before{ content: '最是那一低头的温柔,';}#poem:after{ content: '不胜凉风的娇羞。';}
<p id="poem">像一朵水莲花,</p>运行结果:
2.小示例:
#user{ width: 300px; height: 30px; border: #24164c solid 1px; margin: auto; /*该div居中显示*/ padding:0px; font-size: 14px;}#user input{ width: 200px; height: 30px; margin: 0px; padding: 0px; vertical-align: middle; border:none;}#user:before{ content: ''; width: 31px; height: 24px; display: inline-block; /*默认是行内显示,没有高度的,要通过display属性来使得宽高起作用*/ background: url("icon1.PNG") no-repeat; vertical-align: middle; margin: 0 2px 0 5px; /*上右下左*/}#user:after{ content: ''; width: 25px; height: 25px; display: inline-block; /*只有添加了这个属性,背景图片才会显示出来*/ background: url("icon2.png") no-repeat; vertical-align: middle; /*居中对齐*/ margin: 0 2px 0 20px;}
<div id="user"> <input type="text" value="username"></div>运行效果:
0 0
- CSS3:伪对象选择器
- CSS3的伪对象选择器
- css3 伪类选择器
- css3伪类选择器
- CSS3伪类选择器
- CSS3伪类选择器
- CSS3伪元素选择器
- CSS3选择器--伪类
- css3伪类选择器
- css3 伪元素选择器
- CSS3伪类选择器
- CSS3 结构性伪类选择器
- css3-伪类选择器使用
- 04、CSS3伪类选择器
- CSS3结构性伪类选择器
- CSS3 中的伪类选择器
- CSS3的伪类选择器
- css3新增伪类选择器
- Hibernate与Mysql 5.5创建表出错--table doesn't exist
- Ant+jmeter配置
- Android之.XML布局
- MmGetSystemRoutineAddress和MiFindExportedRoutineByName函数的实现代码
- stat函数讲解
- CSS3:伪对象选择器
- Zlib库的使用实现对zip文件的解压缩(二)
- 新浪实时股票数据接口http://hq.sinajs.cn/list=code
- Android Studio界面介绍
- 蓝牙HC05模块探究-设置AT指令
- Android TextView内容过长加省略号,点击显示全部内容
- 数据结构Java语言实现之链表
- Android EditText输入格式设置
- 『干货』分享你最喜欢的技巧和提示(Xcode,objective-c,swift,c...等等)