一.清零代码:因为不同的浏览器,默认的初始值是不同的,用清零代码把这些默认值高置为0是很有必要的。

  1. 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 {
  2. margin: 0;
  3. padding: 0;
  4. }

二.clearfix:如果有一个DIV作为外部容器,内部的DIV如果设置了float样式,则外部的容器DIV因为内部没有 clear,导致不能被撑开。可用如下代码解决。

  1. .clearfix:after{
  2. content:".";
  3. display:block;
  4. height:0;
  5. clear:both;
  6. visibility:hidden;
  7. }
  8. * html .clearfix{
  9. height:1%;
  10. }

三.ie6不支持position:fixed;的BUG;

  1. /* 除IE6浏览器的通用方法 */
  2. .ie6fixedTL{position:fixed;left:0;top:0}
  3. .ie6fixedBR{position:fixed;right:0;bottom:0}
  4. /* IE6浏览器的特有方法 */
  5. /* 修正IE6振动bug */
  6. * html,* html body{background-p_w_picpath:url(about:blank);background-p_w_upload:fixed}
  7. * html .ie6fixedTL{position:absolute;left:expression(eval(document.documentElement.scrollLeft));top:expression(eval(document.documentElement.scrollTop))}
  8. * 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。

  1. _width:expression((documentElement.clientWidth < 500) ? "500px" : "auto" );//实现min-width
  2. _width:expression((documentElement.clientWidth >500) ? "500px" : "auto" );//实现max-width
  3. _height:expression((documentElement.clientHeight<500) ? "500px" :"auto");//实现min-height
  4. _height:expression((documentElement.clientHeight>500) ? "500px" :"auto");//实现max-height

转载于:https://blog.51cto.com/usual/665952

一些常用的CSS hack代码相关推荐

  1. 兼容ffIE678 hack(IE6、IE7、IE8、Firefox兼容性CSS HACK代码+示例)

    兼容ffIE678 hack(IE6.IE7.IE8.Firefox兼容性CSS HACK代码+示例) 1.区别IE和非IE浏览器CSS HACK代码 #divcss5{ background:blu ...

  2. CSS hack代码汇总

    例如现有CSS代码如下: .divContent{background-color:#eee; } 那么下面我们就来写一下,如何使代码兼容几个主流浏览器. /* IE8+ */ .divContent ...

  3. 常用的 css hack实例

    注意顺序: #menu {  line-height: 23px; }/* firefox 浏览器实行这句定义 */ #menu { line-height: 26px\9; }/*ie6,ie7,i ...

  4. 整理的一些常用的CSS HACK

     ie8以下兼容透明都和支持CSS圆角,这两个都要在服务器上才看到效果,可以本地搭建一个服务器如IIS -pie-background: rgba(255, 255, 255, 0.10);/*IE6 ...

  5. css hack 学习总结

    css hack CSS hack由于不同厂商的浏览器,比如Internet Explorer,Safari,Mozilla Firefox,Chrome等,或者是 同一厂商的浏览器的不同版本,如IE ...

  6. css hack方法,css hack怎么应用

    CSS hack的目的就是使你的CSS代码兼容不同的浏览器,那么你对css hack了解多少呢?下面就让学习啦小编来给你科普一下什么是css hack. css hack的原理 由于不同的浏览器对CS ...

  7. CSShack,CSS hack

    前提:前端开发中,经常遇到浏览器解析不一致,同样的代码,页面展示却不一致的情况,尤其是IE对CSS解析的认识不同,因此我们开发中要想实现得到想要的一致的效果,就会使用到CSS hack 原理 不同的浏 ...

  8. css hack *html,css hack 大全 各个浏览器的css

    各个浏览器的css hack区别属性: IE6: _zoom:1; IE6/7: *zoom:1; IE6/7/8/9 :\9 各个浏览器的css hack区别规则 IE6: *html{} IE7: ...

  9. CSS Hack是什么意思?css hack有什么用?

    第一部分:什么是CSS Hack? CSS hack是通过在CSS样式中加入一些特殊的符号,让不同的浏览器识别不同的符号(什么样的浏览器识别什么样的符号是有标准的,CSS hack就是让你记住这个标准 ...

最新文章

  1. 表格全屏显示_2020-2026年中国手机显示屏市场现状研究分析与发展前景预测报告...
  2. MySQL 高级 - 存储过程 - 语法 - while循环
  3. jQuery-点击按钮实现回到顶部的两种方式
  4. 10. http 的一些说明及分析工具
  5. html 使用符号设置固定链接,让woocommerce使用数字id的固定链接插件
  6. anaconda moviepy_Anaconda和PyCharm的详细安装步骤~小白专用,手把手教学
  7. android自定义radiogroup,Android自定义RadioGroup
  8. startup,startup mount,startup nomount之间的区别
  9. 20155235 《网络攻防》 实验四 恶意代码分析
  10. 【Flink】Flink 1.9 升级 1.12.4 本地可以运行 打包后 集群运行就找不到类 ClassNotFoundException
  11. 一生只有一个配偶的动物,如果一方死亡了,另一方会怎么办?
  12. 大数据将植物学研究带入新境界
  13. Anaconda和conda——关于python的数据科学开发环境,数据科学必备的十大Python库
  14. shell学习笔记二
  15. 一周信创舆情观察(2.1~2.7)
  16. 微信小视频显示服务器正在升级,更新微信版本后 朋友圈小视频提示显示录制时间太短的解决办法...
  17. Day20 网络编程
  18. python两张图片无缝合成一张,Python实现拼接多张图片的方法
  19. 微信小程序页面onLoad获取app.js的onLaunch数据(异步获取用户信息)
  20. 大疆2018校招笔试题

热门文章

  1. 20145309 《信息安全系统设计基础》第5周学习总结
  2. Atitit.mybatis的测试  以及spring与mybatis在本项目中的集成配置说明
  3. HDU ACM 1078 FatMouse and Cheese 记忆化+DFS
  4. weedfs文件使用记录
  5. springboot动态加载native类库
  6. Visual Studio Code(VS code)介绍
  7. day13-(事务mvc反射补充)
  8. 微信小程序 - 更改radio和checkbox选中样式
  9. javasript中var、let和const区别
  10. Leetcode题解(十七)