一.清零代碼:因爲不同的瀏覽器,默認的初始值是不同的,用清零代碼把這些默認值高置爲0是很有必要的。
- body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td {
- margin: 0;
- padding: 0;
- }
二.clearfix:如果有一個DIV作爲外部容器,內部的DIV如果設置了float樣式,則外部的容器DIV因爲內部沒有 clear,導致不能被撐開。可用如下代碼解決。
- .clearfix:after{
- content:".";
- display:block;
- height:0;
- clear:both;
- visibility:hidden;
- }
- * html .clearfix{
- height:1%;
- }
三.ie6不支持position:fixed;的BUG;
- /* 除IE6瀏覽器的通用方法 */
- .ie6fixedTL{position:fixed;left:0;top:0}
- .ie6fixedBR{position:fixed;right:0;bottom:0}
- /* IE6瀏覽器的特有方法 */
- /* 修正IE6振動bug */
- * html,* html body{background-image:url(about:blank);background-attachment:fixed}
- * html .ie6fixedTL{position:absolute;left:expression(eval(document.documentElement.scrollLeft));top:expression(eval(document.documentElement.scrollTop))}
- * html .ie6fixedBR{position:absolute;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)))}
四.ie6不支持max-width、max-height、min-width、min-height的BUG。
- _width:expression((documentElement.clientWidth < 500) ? "500px" : "auto" );//實現min-width
- _width:expression((documentElement.clientWidth >500) ? "500px" : "auto" );//實現max-width
- _height:expression((documentElement.clientHeight<500) ? "500px" :"auto");//實現min-height
- _height:expression((documentElement.clientHeight>500) ? "500px" :"auto");//實現max-height