1.E::selection

2.E::placeholder


1. E::selection

设置对象被选择时的样式。

需要注意的是,::selection只能定义被选择时的background-color,color及text-shadow(IE11尚不支持定义该属性)。

兼容性:

<div class="_selection">
<p>1. Selecting master branch will publish your site from the master branch. This is useful for repositories dedicated to website content.</p>
<p>2. Selecting master branch /docs folder will publish from the /docs folder of your master branch. </p>
<p>3. This lets you maintain documentation and code together on one branch, and open source maintainers can accept contributions for both in a single pull request.</p>
</div>
._selection p::selection{
background: #eb4960;
color: #ffffff;
}

预览:


2. E::placeholder

设置对象文字占位符的样式

::placeholder 伪元素用于控制表单输入框占位符的外观,它允许开发者/设计师改变文字占位符的样式,默认的文字占位符为浅灰色。
当表单背景色为类似的颜色时它可能效果并不是很明显,那么就可以使用这个伪元素来改变文字占位符的颜色。
需要注意的是,除了Firefox是 ::[prefix]placeholder,其他浏览器都是使用 ::[prefix]input-placeholder
Firefox支持该伪元素使用text-overflow属性来处理溢出问题。

兼容性:

代码示例

<div class="_placeholder">
<h1>::placeholder</h1>
<input type="text" placeholder="::placeholder的演示示例"/>
<input type="text" placeholder="::placeholder的演示示例"/>
<input type="text" placeholder="::placeholder的演示示例"/>
<input type="text" placeholder="::placeholder的演示示例"/>
<input type="text" placeholder="::placeholder的演示示例"/>
</div>
._placeholder input {
width: 400px;
margin-bottom: 10px;
}
._placeholder input:nth-child(3n)::-webkit-input-placeholder {
color: #eb4960;
}
._placeholder input:nth-child(3n):-ms-input-placeholder { /* IE10+ */
color: #eb4960;
}
._placeholder input:nth-child(3n):-moz-placeholder{ /* Firefox4-18 */
color: #eb4960;
}
._placeholder input:nth-child(3n)::-moz-placeholder{ /* Firefox19+*/
color: #eb4960;
}
._placeholder input:nth-child(3n+1)::-webkit-input-placeholder {
color: #999999;
}
._placeholder input:nth-child(3n+1):-ms-input-placeholder { /* IE10+ */
color: #999999;
}
._placeholder input:nth-child(3n+1):-moz-placeholder{ /* Firefox4-18 */
color: #999999;
}
._placeholder input:nth-child(3n+1)::-moz-placeholder{ /* Firefox19+*/
color: #999999;
}
._placeholder input:nth-child(3n+2)::-webkit-input-placeholder {
color:#008aff;
}
._placeholder input:nth-child(3n+2):-ms-input-placeholder { /* IE10+ */
color:#008aff;
}
._placeholder input:nth-child(3n+2):-moz-placeholder{ /* Firefox4-18 */
color:#008aff;
}
._placeholder input:nth-child(3n+2)::-moz-placeholder{ /* Firefox19+*/
color:#008aff;
}

效果:

CSS伪对象选择符整理的更多相关文章

  1. #8.10.16总结# 属性选择符 伪对象选择符 CSS的常用样式

    属性选择符 E[att] E[att="val"] E[att~="val"] E[att^="val"] E[att$="val ...

  2. CSS Pseudo-Element Selectors伪对象选择符

    一: CSS3将伪对象选择符(Pseudo-Element Selectors)前面的单个冒号(:)修改为双冒号(::)用以区别伪类选择符(Pseudo-Classes Selectors),但以前的 ...

  3. css伪类选择符

    1):link/:visited/:hover/:active (爱恨原则 love/hate)2):first-child/:last-child/:only-child/:nth-child(n) ...

  4. CSS(二)选择符

     2019-04-11 22:14:23 1.类型选择符(标签选择符)  html中所有的标签都可以直接对元素选择  p em i a html body.....   特点:对页面中所有当前类型的元 ...

  5. CSS3初学篇章_2(伪类选择符)

    id与class选择符 id与class选择符都是自定义标签名字的选择符,但id是唯一的,class却可重复使用. id选择符以"#"定义 class选择符以".&quo ...

  6. CSS那些事儿-阅读随笔1(CSS简介与选择符)

    最近开始详细钻研CSS有关的知识,参考资料是<CSS那些事儿>.将把在此过程中的收获进行记录,方便以后的学习. 一.CSS简介 1.什么是CSS CSS全称为Cascading Style ...

  7. CSS知识点:选择符

    一.选择符的种类 1)通配选择符 它用来给页面所有的元素设置样式 *{margin:0;padding:0;}.但是实际当中不建议这么用,页面中用到了哪些样式,就统一设置样式,因为*影响性能.也可以给 ...

  8. CSS选择符-----伪类选择符

    Element:hover E:hover { sRules }  设置元素在其鼠标悬停时的样式 <!DOCTYPE html> <html> <head> < ...

  9. 学习CSS记录:选择符优先级

    1.标有!important 关键字声明属性. 2.HTML中的CSS样式属性. 3.作者编辑的CSS文件模式属性. 4.用户设置的样式. 5.浏览器默认的样式. ------------------ ...

随机推荐

  1. MyBatis学习练习

    转自:http://ccchhhlll1988-163-com.iteye.com/blog/1415621 基本目的:利用Mybatis完成对一个表简单的select.insert.update.d ...

  2. Git操作指南(2) —— Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并(转)

    关于linux上建库等操作请看文章: http://hi.baidu.com/mvp_xuan/blog/item/30f5b700a832f0261d9583ad.html http://hi.ba ...

  3. 使用boost的deadline_timer实现一个异步定时器

    概述 最近在工作上需要用到定时器,然后看到boost里面的deadline_timer可以实现一个定时器,所以就直接将其封装成了ATimer类,方便使用,ATimer有以下优点: 可以支持纳秒.毫秒. ...

  4. View Controller 视图管理总结

    View controller是iOS中顶层的视图载体和控制器,它需要对view负责,管理view的生命周期,相关处室话以及交互事件,除此以外还需要为view提供合适的数据,以供view使用. Vie ...

  5. C# 之 System.Diagnostics.Process.Start的妙用

    经常会遇到在Winform或是WPF中点击链接或按钮打开某个指定的网址, 或者是需要打开电脑中某个指定的硬盘分区及文件夹, 甚至是"控制面板"相关的东西, 如何做呢? 方法:使用S ...

  6. iOS 网络/本地 图片 按自定义比例缩放 不失真 方法

    我尝试了很多种方法,终于,设计了一个方法,能按自己规定的大小压缩 还没失真 如果以后不好用 我再升级 分享给大家: + (CGRect )scaleImage:(UIImage *)image toS ...

  7. Android(java)学习笔记265:Android线程形态之 HandlerThread

    1.  HandlerThread Android HandlerThread 完全解析 Handler与HandlerThread区别,HandlerThread应用(对比AsyncTask) 备注 ...

  8. [经典算法] 排列组合-N元素集合的所有子集(二)

    题目说明: 给定一组数字或符号,按照字典序产生所有可能的集合(包括空集合),例如给定1 2 3,则可能的集合为:{}.{1}.{1,2}.{1,2,3}.{1,3}.{2}.{2,3}.{3}. 题目 ...

  9. 【Android 界面效果45】ViewPager源码分析

    ViewPager概述: Layout manager that allows the user to flip left and right through pages of data. You s ...

  10. Java Script基础(三) 函数

    一.JavaScript中的函数 在JavaScript中,函数类似于Java中的方法,是执行特定功能的代码块,可以重复调用.JavaScript中的函数分为两种,一种是系统函数,另一种是自定义函数. ...