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. C# redis 分布式session存储

    https://github.com/uliian/SessionExtentionStore 一个基于Redis的Session存储扩展方案,解决ASP.NET中Session的局限性和跨应用程序使 ...

  2. Windows平台下libevent库的使用

    1     引子 手头上有一个使用了4个年头的HttpClient库,自己封装的,对于集成了IE浏览器的应用程序很友好.但最近想把产品扩展到Chrome和FireFox阵营,萌发了重构HttpClie ...

  3. [ES6] 14. Generator -- 1. yield & next()

    Generators in ECMAscript 6 are first-class coroutines that produce encapsulated suspended execution  ...

  4. Spring MVC 3.0 请求转发和重定向

    首先看一下如何获得request对象.session对象: 普通的Controller类,示例代码如下: @Controller @RequestMapping(value = "user& ...

  5. ccConfig(设置一些底层接口状态:是否支持动作叠加 设置fps更新间隔和位置 是否画边框等。。)

    #ifndef __CCCONFIG_H__ #define __CCCONFIG_H__ #include "platform/CCPlatformConfig.h" /** @ ...

  6. swift app中展示折线图, 饼状图, 柱状图等数据图表

    github 下载Charts-master SDK,该SDK有多种可自定义的图表样式 lineChart 正弦余弦线图 LineChart (cubic lines) LineChart (grad ...

  7. linux入侵检测系统snort安装配置

    队长让俺瞅瞅snort,没想到安装配置都遇到问题...整理下过程,给跟我一样的家伙看看.. 由于本人机器是ubuntu,apt-get 几下就可以了,其实网上有不少这样的文章...之所以还要写就是.. ...

  8. Golang学习 - regexp 包

    ------------------------------------------------------------ // 函数 // 判断在 b(s.r)中能否找到 pattern 所匹配的字符 ...

  9. Windows 之 CMD命令

    1. ipconfig 查看 Windows IP 配置 2. ping IP地址 查看远程IP是否通畅 2. ipconfig/flushdns 刷新和重置缓存 3. netsh winsock r ...

  10. 【开源项目7】Android视图注入库:butterknife

    介绍 ButterKnife通过@InjectView和视图的ID注解的变量去找到并自动转换为你布局上相应的布局视图. class ExampleActivity extends Activity { ...