StylizedWeb

Subscribe to our updates:

A Design, WordPress and Tutorials Blog.

Dedicated to helping you learn the art and science of the web.

10 best CSS hacks

If you are front end coder you must know how important is to make cross browses, valid CSS and xHTML code. And also you must know how much time 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..

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

1. Vertical align div

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

2. Min-Height
 
selector {
min-height:500px;
height:auto; !important
height:500px;
}
 
3. PNG transparency

http://stylizedweb.com/2007/12/30/png-transparency-issues/

4. Autoclear
 
.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
 
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
border:0pt none;
font-family:inherit;
font-size:100%;
font-style:inherit;
font-weight:inherit;
margin:0pt;
outline-color:invert;
outline-style:none;
outline-width:0pt;
padding:0pt;
vertical-align:baseline;
}
table {
border-collapse:separate;
border-spacing:0pt;
}
caption, th, td {
font-weight:normal;
text-align:left;
}
blockquote:before, blockquote:after, q:before, q:after {
content:"";
}
blockquote, q {
quotes:"" "";
}
strong {
font-weight:bold;
}
em {
font-style:italic;
}
* {
margin:0pt;
padding:0pt;
}
 
6. Scrolling Render IE
 
html {
      background : url(null) fixed no-repeat;
     }
 
7. Opacity
 
#transdiv {
filter:alpha(opacity=75);
-moz-opacity:.75;
opacity:.75;
}
 
8. PRE Tag
 
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
 
<!--[if lt IE 7]>
<style>
#leftnav li { zoom: 1;} /* haslayout=true */
</style>
 
<![endif]-->
 
10. Good to know
 
@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;}
/**/
 

Leave a comment on Stylized Web Have some feedback? Leave a comment

559 Comments So Far

  1. Its like you read my thoughts! You seem to grasp a lot about this, like you wrote the ebook in it or something. I believe that you simply can do with some percent to force the message house a bit, however other than that, this is magnificent blog. A fantastic read. I’ll certainly be back.

  2. Great weblog here! Also your site a lot up very fast! What web host are you using? Can I am getting your associate link on your host? I wish my site loaded up as quickly as yours lol

  3. i like goood

  4. hvad er det her

  5. Many thanks for this insightful blog article I ultimately appreciate it.

  6. By boyo posted on April 23, 2012 at 7:49 pm

    thankss…

  7. i like goood

  8. By Maschmo posted on May 11, 2012 at 1:57 pm

    Also a good hack:

    display: inline-block; doest work in ie7

    instead you can use:

    zoom: 1;
    *display:inline;

  9. Pingback: Dicas Interessantes #4 | Alvo Conhecimento

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>