float闭合(清除浮动)和CSS HACK

来源:互联网 发布:华为固定网络产品线 编辑:程序博客网 时间:2024/06/06 14:24

一、float 闭合(清除浮动)

  将以下代码加入Global CSS 中,给需要闭合的div加上 class="clearfix" 即可,屡试不爽.


<style>
.clearfix:after
{
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
.clearfix
{
display:inline-block;
}
.clearfix {display:block;}
</style>
二、CSS HACK

  以下两种方法几乎能解决现今所有HACK.
  1, !important
  随着IE7对!important的支持, !important 方法现在只针对IE6的HACK.(注意写法.记得该声明位置需要提前.)

 

<style>
#wrapper
{
width: 100px!important;
width: 80px;
}
</style>

  2, IE6/IE77对FireFox
  *+html 与 *html 是IE特有的标签, firefox 暂不支持.而*+html 又为 IE7特有标签.

 

<style>
#wrapper
{
#wrapper { width: 120px; }
*html #wrapper { width: 80px;}
*+html #wrapper { width: 60px;}
}
</style>


原创粉丝点击