10 best CSS Hacks_ Experience Exchange in Web page production

Source: Internet
Author: User
If you are are front end coder Your must know how important are to make cross browses, valid CSS and XHTML code. And also you must know, we are 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.

This is the list of hand picked CSS hacks and tricks which can help your in your CSS code and also save some time.

1. Vertical Align Div (vertically centered)

http://stylizedweb.com/2008/02/01/vertical-align-div/

2. Min-height (minimum 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 (automatic removal)

. 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 pre-format)

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 label 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;}
/**/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.