Ten CSS tricks you may not know
and
Ten CSS tricks — corrected and improved
Well, no news for me at all but it is really good to have them in one place.
I would like to add there some
- :hover directive trick for any element (using IE CSS behavior):
div#myDiv {behavior: url(h.htc)};
– better to add some default class also 🙂
div#myDiv.hover, div#myDiv:hover {border: 1px solid red;} - xhtml [xmlns] hack for Mozilla browsers: at the top or css doc just add
[xmlns] {};
. NB: Works only for xhtml
div#myBlock {background-color: green;} /* for IE, Opera etc */
[xmlns] div#myBlock {background-color: red;} /* for Mozilla Gecko Only */
- fieldsets & labels using for forms instead of tables (very useful)
input[type="submit"] {background-color: red;} /* for non-IE */
input {background-color: black; background-color: expression(this.type=='submit'?'red':'black');} /* for IE */-
oveflow: -moz-scrollbars-vertical;
for Mozilla scroller -
html,body {padding: 0; margin: 0;}
for position: fixed emulation on IE
div#fxd {
position: fixed !important;
position: absolute;
top: 25px;
left: 15px;
top: expression(body.scrollTop+25+'px');
}