more: http://www.lesliefranke.com/files/reference/csscheatsheet.html, http://www.pxleyes.com/blog/wp-content/uploads/2010/03/css-cheatsheet-portrait.pdf
Selector | ||
* | All elements | |
div | <div> | |
div * | All elements within <div> | |
div span | <span> within <div> | |
div, span | <div> and <span> | |
div > span | <span> with parent <div> | |
div + span | <span> preceded by <div> | |
.class | Elements of class "class" | |
div.class | <div> of class "class" | |
#itemid | Element with id "itemid" | |
div#itemid | <div> with id "itemid" | |
a[attr] | <a> with attribute "attr" | |
a[attr='x'] | <a> when "attr" is "x" | |
a[class~='x'] | <a> when class is a list containing 'x' | |
a[lang|='en'] | <a> when lang begins "en" | |
Pseudo-Selectors and Pseudo-Classes | ||
:first-child | First child element | |
:first-line | First line of element | |
:first-letter | First letter of element | |
:hover | Element with mouse over | |
:active | Active element | |
:focus | Element with focus | |
:link | Unvisited links | |
:visited | Visited links | |
:lang(var) | Element with language "var" | |
:before | Before element | |
:after | After element | |
Sizes and Colours | ||
0 | 0 requires no unit | |
Relative Sizes |
em: 1em equal to font size of parent (same as 100%) ex: Height of lower case "x" %: Percentage | |
Absolute Sizes: |
px: Pixels cm: Centimeters mm: Millimeters in: Inches pt: 1pt = 1/72in pc: 1pc = 12pt | |
Colours: |
#789abc: RGB Hex Notation #acf: Equates to "#aaccff" rgb(0,25,50): Value of each of red, green, and blue. 0 to 255, may be swapped for percentages. rgba(0, 0, 0, 0.39): red, green, blue, transparent(0-1) | |
box | margin, margin-top, margin-right, margin-bottom, margin-left padding, padding-top, padding-right, padding-bottom, padding-left border, border-top, border-bottom, border-right, border-left border-color, border-top-color, border-right-color, border-bottom-color, border-left-color border-style, border-top-style, border-right-style, border-bottom-style, border-left-style border-width, border-top-width, border-right-width, border-bottom-width, border-left-width | |
Dimension | width, min-width, max-width height, min-height, max-height vertical-align | |
Cursor (Move mouse over for testing) More | cursor: auto | the default cursor |
cursor: crosshair | gun-style cross | |
cursor: default | no change | |
cursor: pointer; cursor: hand | the normal link-hand | |
cursor: wait | the hourglass | |
cursor: text | the text-selecting 'I-beam' | |
cursor: help | an arrow with a question-mark | |
cursor: move | crosshair with arrows on the ends | |
Responsive | @media (max-width:770px) {} | |
Centering | ||
for text | p,h1{text-align: center} | |
for page | .center {max-width: 500px;margin: 0px auto;} | |
for image | img.displayed { display: block; margin-left: auto; margin-right: auto } <img class="displayed" src="..." alt="..."> | |
for block | p.blocktext { margin-left: auto; margin-right: auto; width: 6em } <p class="blocktext">This rather...</p> | |
centering vertically | div.container { min-height: 10em; display: table-cell; vertical-align: middle } <divclass="container"> <P>This small paragraph...</p> </div> | |
centering vertically (in CSS level 3) | div.container { height: 10em; position: relative } /* 1 */ div.container p { margin: 0; position: absolute; /* 2 */ top: 50%; /* 3 */ transform: translate(0, -50%) } /* 4 */ <div class=container3> <p>This paragraph… </div> The essential rules are: 1. Make the container relatively positioned, which declares it to be a container for absolutely positioned elements. 2. Make the element itself absolutely positioned. 3. Place it halfway down the container with 'top: 50%'. (Note that 50%' here means 50% of the height of the container.) 4. Use a translation to move the element up by half its own height. (The '50%' in 'translate(0, -50%)' refers to the height of the element itself.) | |
centering in the viewpoint (in CSS level 3) | section { background: black; color: white; border-radius: 1em; padding: 1em; position: absolute; top: 50%; left: 50%; margin-right: -50%; transform: translate(-50%, -50%) } <section> <h1>Nicely centered</h1> <p>This text block is vertically centered. <p>Horizontally, too, if the window is wide enough. </section> | |
Font (Google fonts resources) | ||
Font |
p{ font: font-style font-variant font-weight font-size/line-height font-family|caption|icon|menu|message-box|small-caption|status-bar|initial|inherit; /*caption, icon, menu, message-box, small-caption, status-bar, initial, inherit have no obvious effect*/ font: 15px arial, sans-serif; font: italic 20px Serif; font: italic bold 12px/30px Georgia, serif; } | |
Font Stacks |
/* Times New Roman-based stack */ font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif; /* Modern Georgia-based serif stack */ font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif; /* Traditional Garamond-based serif stack */ font-family: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif; /* Helvetica/Arial-based sans serif stack */ font-family: Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT", "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif; /* Verdana-based sans serif stack */ font-family: Corbel, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif; /* Trebuchet-based sans serif stack */ font-family: "Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif; /* Impact-based sans serif stack */ font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans-serif; /* Monospace stack */ font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; | |
@font-face |
@font-face {font-family: DeliciousRoman; src: url(http://www.font-face.com/fonts/delicious/Delicious-Roman.otf);} p {font-family: DeliciousRoman, Helvetica, Arial, sans-serif;} |
|
font-weight | normal, bold, bolder, lighter, number, initial, inherit | |
no underline(for link) | a {text-decoration:none} | |
Link effects |
Creative Link Effects Icon Hover Effects Hover.css |
|
Change Text Selection Color |
::selection { background: #ffb7b7; /* WebKit/Blink Browsers */ } ::-moz-selection { background: #ffb7b7; /* Gecko Browsers */ } /*Within the selection selector, color and background are the only properties that work. */ | |
three columns | .three-column { padding: 1em; -moz-column-count: 3; -moz-column-gap: 1em; -webkit-column-count: 3; -webkit-column-gap: 1em; column-count: 3; column-gap: 1em; }
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Mauris ante ligula, facilisis sed ornare eu, lobortis in odio. Praesent convallis urna a lacus interdum ut hendrerit risus congue. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac.
|
|
Drop Caps |
p:first-of-type::first-letter { font-size:300%; color: red; } Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris tristique lobortis orci ac lacinia. Fusce eu purus eget diam vehicula auctor nec eu elit. Morbi consequat facilisis orci vel malesuada. Donec ultrices molestie sollicitudin. Aliquam pharetra libero enim. Donec et suscipit massa. Donec dui odio, dignissim non sodales et, tincidunt a sapien. Phasellus elit nibh, adipiscing sed blandit vel, interdum et arcu. | |
image | ||
Flip image |
img { -moz-transform: scaleX(-1); -o-transform: scaleX(-1); -webkit-transform: scaleX(-1); transform: scaleX(-1); filter: FlipH; -ms-filter: "FlipH"; } | |
Shadow, Blur | ||
shadow | 3px 3px 5px 6px #ccc: horizontal offset, vertical offset, blur radius(optional), spread radius(optional), Color | |
.shadow { -webkit-box-shadow: 0 8px 6px -6px black; -moz-box-shadow: 0 8px 6px -6px black; box-shadow: 0 8px 6px -6px black; } |
.shadow { -moz-box-shadow: 3px 3px 5px 6px #ccc; -webkit-box-shadow: 3px 3px 5px 6px #ccc; box-shadow: 3px 3px 5px 6px #ccc; } | |
//text-shadow .blur { color: transparent;text-shadow: 0 0 5px #333; } Hello |
.multiple-shadow{ text-shadow: 1px 1px 1px #000, 3px 3px 5px blue; } Hello
| |
ease transition: transition: [property] 0.3s ease-in-out; -moz-transition: [property] 0.3s ease-in-out; -webkit-transition: [property] 0.3s ease-in-out; |
.shadow{display:block;padding:10px 10px;margin:5px 15px; background-color: #fff; box-shadow: 0 1px 3px rgba(34, 25, 25, .4); -moz-box-shadow: 0 1px 3px rgba(34, 25, 25, .4); -webkit-box-shadow: 0 1px 3px rgba(34, 25, 25, .4); filter: progid:DXImageTransform.Microsoft.Shadow(color = #adacac, direction = 135, strength = 2); transition: box-shadow 0.3s ease-in-out; -moz-transition: -moz-box-shadow 0.3s ease-in-out; -webkit-transition: -webkit-box-shadow 0.3s ease-in-out;padding:0 10px;} .shadow:hover { box-shadow: 0 1px 5px rgba(34, 25, 25, .8); -moz-box-shadow: 0 1px 5px rgba(34, 25, 25, .8); -webkit-box-shadow: 0 1px 5px rgba(34, 25, 25, .8); filter: progid:DXImageTransform.Microsoft.Shadow(color = #979797, direction = 135, strength = 3); } | |
rotate | transform:rotate(90deg); -ms-transform:rotate(90deg); /* IE 9 */ -webkit-transform:rotate(90deg); /* Opera, Chrome, and Safari */ | |
Navbar center | .navbar{margin: 0 auto;width: 100%;text-align: center;height:70px;position:fixed;top:0;} .navbar ul{list-style: none;} .navbar li{display: inline-block;}//(!important, to center) .navbar a{height:100%;} | |
Sticky Footer <div class="page-wrap"> Content </div> <footer class="site-footer"> Footer </footer> |
* { margin: 0; } html, body { height: 100%; } .page-wrap { min-height: 100%; /* equal to footer height */ margin-bottom: -142px; } .page-wrap:after { content: ""; display: block; } .site-footer, .page-wrap:after { height: 142px; } .site-footer { background: orange; } | |
Button With Line Breaks | <input type="button" value="Really
Tall
 Button"> | |
3D effect, 2 color, text | 3D text Example Lobster in a box | |
Button style | ||
Tucked Corners
|
.corners { background: #f6f6f6; height: 70px; margin: 50px auto; padding:20px 5px 5px 15px; max-width: 600px; position: relative; width: 80%; -webkit-box-shadow: 0 1px 7px hsla(0,0%,0%,.2); -moz-box-shadow: 0 1px 7px hsla(0,0%,0%,.2); box-shadow: 0 1px 7px hsla(0,0%,0%,.2); } /* Corner Effect */ .corners:after, .corners:before { background: #e6e6e6; content: ''; height: 50px; position: absolute; top: -25px; width: 100px; -webkit-box-shadow: 0 5px 10px -7px hsla(0,0%,0%,.5); -moz-box-shadow: 0 5px 10px -7px hsla(0,0%,0%,.5); box-shadow: 0 5px 10px -7px hsla(0,0%,0%,.5); } .corners:after { left: -50px; -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); -o-transform: rotate(-45deg); transform: rotate(-45deg); } .corners:before { right: -50px; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); } |
|
stitched | Stitched | |
corner ribbon |
NEWS | |