Article Introduction: 22 CSS Tips that must be known. |
1, change the background and color of selected text
- :: selection{/* Safari and Opera *
- Background: #c3effd;
- Color: #000;
- }
- ::-moz-selection{/* Firefox *
- Background: #c3effd;
- Color: #000;
- }
2, to prevent the red fox roll Jump
- html{Overflow-y:scroll;}
3, Paging printing
- . page-break{Page-break-before:always;}
4. Use!important
- . page {background-color:blue!important; background-color:red;}
5, the image replaces the text
- . header{
- text-indent:-9999px;
- Background:url (' someimage.jpg ') no-repeat;
- height:100px; /*dimensions equal to Image size*/
- width:500px;
- }
6, the minimum height of compatible browsers
- #container {
- Height:auto!important;/*all browsers except IE6 'll respect the!important flag*/
- min-height:500px;
- Height:500px;/*should have the same value as the min height above*/
- }
7, the new window open link highlighted
- a[target= "_blank"]:before,
- a[target= "new"]:before {
- margin:0 5px 0 0;
- padding:1px;
- outline:1px solid #333;
- Color: #333;
- Background: #ff9;
- font:12px "Zapf Dingbats";
- Content: "\279c";
- }
8, beautify the Li serial number
- OL {
- Font:italic 1em Georgia, times, serif;
- Color: #999999;
- }
- OL p {
- Font:normal 8em Arial, Helvetica, Sans-serif;
- Color: #000000;
- }
9, the first word sinks
- p:first-letter{
- Display:block;
- margin:5px 0 0 5px;
- Float:left;
- Color: #FF3366;
- Font-size:3.0em;
- Font-family:georgia;
- }
10, compatible with the browser opacity
- . transparent_class {
- Filter:alpha (OPACITY=50);
- -moz-opacity:0.5;
- -khtml-opacity:0.5;
- opacity:0.5;
- }
11, using Line-height to achieve vertical center
- line-height:30px;
12, center layout
- body{
- width:1000px;
- margin:0 Auto;
- }
13. Remove the vertical scroll bar of IE text field
- textarea{
- Overflow:auto;
- }
14. Move the dotted box of hyperlinks
- A:active, a:focus{Outline:none;
15, ie the element disappears, add to the element
- position:relative;
16, according to the link is not the same, add different icons
- A[href$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$= '. Doc '] {
- padding:0 20px 0 0;
- Background:transparent URL (/graphics/icons/doc.gif) no-repeat Center right;
- }
17, CSS hand-click Style
- Input[type=submit],label,select,.pointer {cursor:pointer;}
18, Letter Capital
- Text-transform:capitalize;
19, all English capitals, and the first letter is larger than the other
- Font-variant:small-caps;
20, highlighted text box, does not support IE
- Input[type=text]:focus, input[type=password]:focus{
- border:2px solid #000;
- }
21, remove the IMG border
- A img{border:none;}
22, use the label to achieve no form form
Username
Username
- P label{
- width:100px;
- Float:left;
- margin-right:10px;
- Text-align:right;
- }