Thursday, December 20, 2007

Dynamic Height Code

Here is a css code called clearfix:

.clearfix:after {
content: ".";
display: block;
height: 0px;
clear: both;
visibility: hidden;
}
.clearfix {display: inline-block;}

/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */


Use it when items in a container is longer than the outer container or is unpredictable. This css code will make the outer container have a fixed height. Then you could use Element.getDimensions() to get the computed css height of that container.

2 comments:

Anonymous said...

This is great info to know.

Birmingham Cleaners said...

Great share thanks for posting

Subscribe in a Reader