10 best CSS Hacks_ experience Exchange in Web authoring

Source: Internet
Author: User
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)





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.