一.清零代码:因为不同的浏览器,默认的初始值是不同的,用清零代码把这些默认值高置为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-p_w_picpath:url(about:blank);background-p_w_upload: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