Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mislz28/public_html/wp-content/themes/css-faq-v2/timeweather/timeweather.php on line 19
  • Uncategorized
7 March 2008

CSS Hacks for You! (First Serving)

Dejan Cancarevic sort of whispered this to me and I’m whispering it to you in return. I guarantee personally that these hacks are really among the BEST hacks I’ve tried so far. They made my pages quite amazing and I want yours to be the same too. So, without further ado, go get mouse right on gear and copy this stuff.

1. Vertical align div

Idea is to place absolute div 50% left and top and then to move margin left and top half if it’s size.

img

.wrapper {width: 100px;height: 100px;position: absolute;top: 50%;left: 50%;margin-left: -50px;margin-top: -50px;}

Problem?

This works only with defined height and when div height is less then browser height so you can’t have scroll.

Solution

<div id=”shim”/></div><div id=”wrapper”>Content</div>html, body {height: 100%;margin: 0;padding: 0;

}

* {

margin:0px auto;

padding:0;

}

div#shim {

visibility: hidden;

width: 100%;

height: 50%;

margin-top: -200px;

float: left;

}

div#wrapper {

width: 1000px;

height: 400px;

clear: both;

background:red;

position: relative;

top: -200px;

/* IE4ever Hack: Hide from IE4 **/

position: static;

/** end hack */

}

/* Hide from IE5mac \*//*/

div#shim {

display: none;

}

html, body {

height: auto;

}

/* end hack */</font>

Check it out real-time at http://stylizedweb.com/2008/02/01/vertical-align-div/.

2. Min-Height

selector {

min-height:500px;

height:auto; !important

height:500px;

}

3. PNG transparency

img

<!–[if lt IE 7.]>

<script defer type=”text/javascript” src=”pngfix.js”></script>

<![endif]–>

Second sample…

img

.someelement {

background-image: url(images/image.png);

}

* html .someelemen {

background-color: #333;

back\ground-color: transparent;

background-image: url(images/blank.gif);

filter: progid:DXImageTransform.Microsoft.

AlphaImageLoader(src=”images/image.png”, sizingMethod=”scale”);

}

See more about PNG Transparency at http://stylizedweb.com/2007/12/30/png-transparency-issues/.

Tags:

Esta entrada fue publicada en7 March 2008a las13:06 y esta registrada en Uncategorized. Puedes seguir cualquier comentario a esta entrada a través delRSS 2.0feed. Puedes dejar un comentario, o rastrear desde tu sitio web

2 comments so far

1. 

thanks for mentioning me

7 March 2008 at 14:42
2. 
admin

Dejan, you are very welcome here:) Stay connected.

8 March 2008 at 0:49

Dejar un comentario

Name (*)
Mail (will not be published) (*)
URI
Comentario