日期:2014-05-17  浏览次数:20580 次

CSS选择器基础笔记
CSS selectors
1)[attribute] base on Attribute
a[href] { text-decoration: none; }

2)[attribute=val] base on the Value of an attribute
a[href="www.iteye.com"]{ text-decoration: none; }

3)[attribute~=val] contain the space-separated attribute somewhere in the value
a[title~="tv hd digital"] { text-decoration: none; }
/* if title's value contains the word 'tv' or 'hd' or 'digital', then apply the CSS */

4)[attribute|=val] contain the attribute with a hyphen, must start with the value
a[title|="apple"] { color: red; }
/* <a title="apple-banana">link</a> */

CSS3
1)[attribute^=val] attribute’s value begins with val
a[href^="mailto:"] { color: red; }

2)[attribute$=val] attribute’s value ends with val
a[href$='.rss'] { color: red; }

3)[attribute*=val] attribute value is anywhere within val
a[href *="username"] { color: red; }