Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
notes:css_cheat_sheet [2008/08/15 01:33] smthng created |
notes:css_cheat_sheet [2008/08/21 00:18] (current) smthng |
||
---|---|---|---|
Line 10: | Line 10: | ||
* Styles define how to display HTML elements. Style sheets are collections of styles. | * Styles define how to display HTML elements. Style sheets are collections of styles. | ||
* Multiple style sheets will cascade into a single style definition. | * Multiple style sheets will cascade into a single style definition. | ||
- | * Styles can be specified inside | + | * There are 3 ways to specify styles (decreasing priority): |
- | | + | - inline as an element |
- | * Multiple property-value pairs may be separated by semi-colons. | + | - in an internal style sheet in the head <code html> |
- | * Multiple selectors must be separated by commas | + | < |
- | * Values must be quoted if they are multiple words | + | <!-- |
+ | hr {color: sienna} | ||
+ | --> | ||
+ | </ | ||
+ | - in an external | ||
+ | <link rel=" | ||
+ | href=" | ||
+ | |||
+ | |||
+ | ==== CSS Syntax==== | ||
+ | CSS syntax is made up of three parts - selector {property: value}. | ||
+ | * Multiple property-value pairs may be separated by semi-colons. | ||
+ | * Multiple selectors must be separated by commas | ||
+ | * Values must be quoted if they are multiple words | ||
* A simple example <code html> | * A simple example <code html> | ||
h1,h2,h3 { | h1,h2,h3 { | ||
Line 20: | Line 33: | ||
color: black; | color: black; | ||
font-family: | font-family: | ||
+ | * Classes allow groups of elements to share formatting e.g. <code html> | ||
+ | p.right {text-align: | ||
+ | .blue {color: blue} | ||
+ | <p class=" | ||
+ | * Styles can also match on attribute values or id e.g. <code html> | ||
+ | input[type=" | ||
+ | #id {background-color: | ||
+ | p#id {background-color: | ||
+ | * CSS uses C-style comments - /* comment */ . | ||
+ | |||
+ | ==== CSS Background/ | ||
+ | * Background properties examples <code html> | ||
+ | background-color: | ||
+ | background-image: | ||
+ | background-repeat: | ||
+ | background-attachment: | ||
+ | background-position: | ||
+ | background: blue url(' | ||
+ | </ | ||
+ | * Text properties examples <code html> | ||
+ | color: # | ||
+ | text-align: left/ | ||
+ | letter-spacing: | ||
+ | white-space: | ||
+ | text-decoration: | ||
+ | text-transform: | ||
+ | </ | ||
+ | * Font properties examples <code html> | ||
+ | font-family: | ||
+ | font-size-adjust: | ||
+ | font-style: italic/ | ||
+ | font-weight: | ||
+ | font: italic small-caps 900 12px arial | ||
+ | font: caption/ | ||
+ | |||
+ | ==== CSS Border/List Properties ==== | ||
+ | * Border properties examples (btlr=bottom/ | ||
+ | border-style: | ||
+ | dashed/ | ||
+ | border-btlr: | ||
+ | border-width: | ||
+ | border-color: | ||
+ | outline-color/ | ||
+ | * A margin describes space around the element. Padding defines the space between border and content.< | ||
+ | margin: width x 4 (trbl); margin-btlr | ||
+ | padding: width x 4 (trbl); padding-btlr</ | ||
+ | * List properties examples <code html> | ||
+ | list-style-type: | ||
+ | list-style-type: | ||
+ | list-style-image: | ||
+ | list-style-position: | ||
+ | list-style: type position image</ | ||
+ | * Table properties examples <code html> | ||
+ | table-layout: | ||
+ | border-collapse: | ||
+ | border-spacing: | ||
+ | </ | ||
+ | |||
+ | ==== Sizing and Positioning CSS Properties ==== | ||
+ | |||
+ | * Size properties examples <code html> | ||
+ | height/ | ||
+ | min/ | ||
+ | line-height: | ||
+ | |||
+ | * Position properties <code html> | ||
+ | display: inline/ | ||
+ | float: btlr ; | ||
+ | position: relative(to normal)/ | ||
+ | /fixed(rel to window, doesn' | ||
+ | bottom/ | ||
+ | vertical-align: | ||
+ | |||
+ | * Visibility properties <code html> | ||
+ | visibility: | ||
+ | clear: | ||
+ | clip: rect(10px, 5px, 10px, 5px) | ||
+ | overflow: | ||
+ | z-index: 1 (0 is normal) </ | ||
+ | |||
+ | ==== Advanced CSS ==== | ||
+ | * Pseudo classes can restrict the selector. a:hover and a:active may have to come after a:link and a:visited. <code html> | ||
+ | selector.class: | ||
+ | a:link {color: # | ||
+ | a:visited {color: # | ||
+ | a:hover {color: blue} (mouse-over element) | ||
+ | a:active {color: #0000FF} (selected element) | ||
+ | a:focus {color: #0000FF} (focused element - not in IE) | ||
+ | p: | ||
+ | p > em: | ||
+ | </ | ||
+ | * Pseudo elements are dynamic elements <code html> | ||
+ | p: | ||
+ | h1:before {} ; h1:after {} ;</ | ||
+ | * @media allows different styles for different media. Media examples include screen, print, handheld, projection, tty, tv, aural, braille. <code html> @media screen, | ||
+ | * Misc Properties <code html> | ||
+ | opacity: | ||
+ | filter: | ||
+ | |||
+ | onmouseover=" | ||
+ | this.filters.alpha.opacity=100" | ||
+ | onmouseout=" | ||
+ | this.filters.alpha.opacity=40" | ||
+ | |||
+ | cursor: |