css 属性选择器笔记
生活随笔
收集整理的這篇文章主要介紹了
css 属性选择器笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、基本選擇器:
?
eg:
*{margin:0;padding:0}p{color:black}.content{background:red;}#intro{padding-left:2em;}?
2、多元素組合選擇器
?
?
div p { color:#f00; }#nav li { display:inline; }#nav a { font-weight:bold; }div > strong { color:#f00; }h2 + p { color:#f00; }?
三、CSS 2.1 屬性選擇器
eg:
p[title] { color:#f00; }div[class=error] { color:#f00; }td[headers~=col1] { color:#f00; }p[lang|=en] { color:#f00; }blockquote[class=quote][cite] { color:#f00; }四、CSS 2.1中的偽類
eg
p:first-child { font-style:italic; }input[type=text]:focus { color:#000; background:#ffe; }input[type=text]:focus:hover { background:#fff; }q:lang(sv) { quotes: "\201D" "\201D" "\2019" "\2019"; }五、 CSS 2.1中的偽元素
eg:
p:first-line { font-weight:bold; color;#600; }.preamble:first-letter { font-size:1.5em; font-weight:bold; }.cbb:before { content:""; display:block; height:17px; width:18px; }background:url(top.png) no-repeat 0 0; margin:0 0 0 -18px; }a:link:after { content: " (" attr(href) ") "; }?
六、CSS 3的同級元素通用選擇器
eg:
p ~ ul { background:#ff0; }?
七、CSS 3 屬性選擇器
eg:
div[id^="nav"] { background:#ff0; }?
八、CSS 3中與用戶界面有關的偽類
?
?
input[type="text"]:disabled { background:#ddd; }?
九、CSS 3中的結構性偽類
?eg
p:nth-child(3) { color:#f00; }p:nth-child(odd) { color:#f00; }p:nth-child(even) { color:#f00; }p:nth-child(3n+0) { color:#f00; }p:nth-child(3n) { color:#f00; }tr:nth-child(2n+11) { background:#ff0; }tr:nth-last-child(2) { background:#ff0; }p:last-child { background:#ff0; }p:only-child { background:#ff0; }p:empty { background:#ff0; }?
十、CSS 3的反選偽類
?
十一、CSS 3中的 :target 偽類
?
轉自:http://www.ruanyifeng.com/blog/2009/03/css_selectors.html
?
在寫css屬性選擇器時注意特殊性的值得權重
?
轉載于:https://www.cnblogs.com/feilu2016/p/7115988.html
總結
以上是生活随笔為你收集整理的css 属性选择器笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦里梦到流星雨代表什么
- 下一篇: OBJECT_ID()的使用方法