If you were front end coder You must know how important was to make cross browses, valid CSS and XHTML code. And also must know how much time we is spending in all those hacks and fixes for various browsers. I ' ve written about some of them earlier on PNG transparency issues, Yellow fields in Web Form, Vertical align div etc.
Here is the list of ten hand picked CSS hacks and tricks which can help you in your CSS code and also save some time.
1. Vertical Align Div (vertical center)
http://stylizedweb.com/2008/02/01/vertical-align-div/
2. Min-height (min. height)
selector {
min-height:500px;
Height:auto;!important
height:500px;
}
3. PNG transparency (transparent PNG)
http://stylizedweb.com/2007/12/30/png-transparency-issues/
4. Autoclear (Auto Clear)
. container:after {
Content: ".";
Display:block;
height:0;
Clear:both;
Visibility:hidden;
}
. container {display:inline-table;}
/* Hides from Ie-mac \*/
* HTML. Container {height:1%;}
. container {Display:block;}
/* End Hide from Ie-mac */
5. Reset css (CSS reset)
Body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,
FIELDSET,INPUT,P,BLOCKQUOTE,TH,TD {
margin:0; padding:0;
}
Table {border-collapse:collapse;border-spacing:0;}
fieldset,img {border:0;}
Address,caption,cite,code,dfn,em,strong,th,var {
Font-style:normal;font-weight:normal;
}
Ol,ul {list-style:none;}
caption,th {text-align:left;}
H1,h2,h3,h4,h5,h6 {font-size:100%;}
Q:before,q:after {content: ";}
6. Scrolling render IE (ie scroll bar rendering)
HTML {
Background:url (null) fixed no-repeat;
}
7. Opacity (transparency)
#transdiv {
Filter:alpha (opacity=75);
-moz-opacity:.75;
opacity:.75;
}
8. Pre tag (label preformatted)
Pre {
White-space:pre-wrap; /* css-3 */
White-space:-moz-pre-wrap!important; /* Mozilla, since 1999 */
White-space:-pre-wrap; /* Opera 4-6 */
White-space:-o-pre-wrap; /* Opera 7 */
Word-wrap:break-word; /* Internet Explorer 5.5+ */
}
9. Li Background Repeat IE (li tag Background repeat)
<!–[if LT IE 7]>
<style>
#leftnav li {zoom:1;}/* Haslayout=true */
</style>
<! [endif]–>
Good to Know (best known)
@charset "Utf-8″;
/* ———————————————————————-
WinIE7
———————————————————————- */
*:first-child+html Selector{property:value;}
/* ———————————————————————-
WinIE6 & Mac IE
———————————————————————- */
* HTML Selector{property:value;}
/* ———————————————————————-
WinIE6
———————————————————————- */
/*\*/
* HTML Selector{property:value;}
/**/
/* ———————————————————————-
Macie
———————————————————————- */
/*\*//*/
Selector{property:value;}
/**/