文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>CSS HACK 与float浮动代码

CSS HACK 与float浮动代码

时间:2010-11-26  来源:秩名

css hack由于不同的浏览器,比如internet explorer 6,internet explorer 7,mozilla firefox等,对css的解析认识不一样,因此会导致生成的页面效果不一样,得不到我们所需要的页面效果。 这个时候我们就需要针对不同的浏览器去写不同的css,让它能够同时兼容不同的浏览器,能在不同的浏览器中也能得到我们想要的页面效果。

一、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> 

  注意:
  *+html 对ie7的hack 必须保证html顶部有如下声明:
  <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "">

 

二、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> 

 

标签分类:

相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载