CSS
Table of Contents
Selectors
[attr="value"] /* = exact */
[class~="box"] /* ~= has word */
[class|="icon"] /* |= exact, or prefix (eg, value-) */
[href$=".doc"] /* $= ends in */
[class*="-is-"] /* *= contains */
h3 + p /* + adjacent sibling */
article ~ footer /* ~ far sibling */
.container > .box /* > direct child */
:target (h2#foo:target)
:disabled
:nth-child
:nth-child(3n)
:nth-child(3n+2)
:nth-child(-n+4)
:nth-last-child(...)
:first-of-type
:last-of-type
:nth-of-type
:only-of-type - only child of its parent thats like that
:only-childClearfix
Font
Font Antialiasing / Smoothing
Ref - Link
Background
Custom Selectbox
Note: only works with webkit browsers, others will give you fallback.
CSS Selection
Placeholder Styling
Truncate String with Ellipsis
All the following are required, so the text must be in a single straight line that overflows a box where that overflow is hidden.
More techniques here, including multi-line ellipsis.
Default list styling
Use :not() to Apply/Unapply Borders on Navigation
:not() to Apply/Unapply Borders on NavigationInstead of putting on the border...
...and then taking it off the last element...
...use the :not() pseudo-class to only apply to the elements you want:
Sure, you can use .nav li + li or even .nav li:first-child ~ li, but with :not() the intent is very clear and the CSS selector defines the border the way a human would describe it.
IE Browser Specific Conditions
The following table describes the operators that can be used to create conditional expressions.
!
[if !IE]
The NOT operator. This is placed immediately in front of the feature, operator, or subexpressionto reverse the Boolean meaning of the expression.
lt
[if lt IE 5.5]
The less-than operator. Returns true if the first argument is less than the second argument.
lte
[if lte IE 6]
The less-than or equal operator. Returns true if the first argument is less than or equal to the second argument.
gt
[if gt IE 5]
The greater-than operator. Returns true if the first argument is greater than the second argument.
gte
[if gte IE 7]
The greater-than or equal operator. Returns true if the first argument is greater than or equal to the second argument.
( )
[if !(IE 7)]
Subexpression operators. Used in conjunction with boolean operators to create more complex expressions.
&
[if (gt IE 5)&(lt IE 7)]
The AND operator. Returns true if all subexpressions evaluate to true
css[if (IE 6)
Last updated