惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - ゞ智者.千虑

获取 Google PR 值 ASP(vbs)版 (使用最新算法) Adobe CS4 Design Premium 简体中文正式版全集 提供种子文件 破解方法 jQuery1.4 API 中文版手册(chm格式) ASCII码表 解决在IE7下Ext表单(form)过长的时候fieldset内组件错位的BUG jQuery1.3 API 中文版手册(chm格式) FCKeditor的fckconfig.js配置 中文说明 - ゞ智者.千虑 - 博客园 关于Ext ComboBox组件的expand()方法 - ゞ智者.千虑 - 博客园 Adobe DreamweaverCS4 beta 下载地址+序列号+中文包+破解 全攻略o(∩_∩)o... 清除浮动的最优方法 Adobe DreamweaverCS4 beta+可用序列号,FireworkCS4 beta及SoundboothCS4 beta 官方下载地址 关于IE6处理块级元素内部的问题 - ゞ智者.千虑 - 博客园 Dreamweaver CS4 Prerelease 关于远程桌面与本地计算机之间的复制、粘贴 jQuery 1.2 cheatsheet IE6.0图片下空隙问题解决方法集合 关于IIS 7.0 局域网无法访问的解决方法 China VS USA [转]ajax:拥抱json,让xml走开
IE6/IE7/FF CSS HACK
ゞ智者.千虑 · 2008-04-17 · via 博客园 - ゞ智者.千虑

一、CSS HACK
以下两种方法几乎能解决现今所有HACK.

1, !important
随着IE7对!important的支持, !important 方法现在只针对IE6的HACK.(注意写法.记得该声明位置需要提前.)

CSS代码

  1. <style>   
  2. #wrapper {   
  3. width100px!important  
  4. width80px  
  5. }   
  6. </style>   

2, IE6/IE77对FireFox

*+html 与 *html 是IE特有的标签, firefox 暂不支持.而*+html 又为 IE7特有标签.

CSS代码

  1. <style>   
  2. #wrapper { width120px; }   
  3. *html #wrapper { width80px;}   
  4. *+html #wrapper { width60px;}   
  5. </style>  

注意:
*+html 对IE7的HACK 必须保证HTML顶部有如下声明:

XML/HTML代码

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  

 二、万能 float 闭合(非常重要!)

关于 clear float 的原理可参见 [How To Clear Floats Without Structural Markup]
将以下代码加入Global CSS 中,给需要闭合的div加上 class="clearfix" 即可,屡试不爽.

CSS代码

  1. <style>   
  2.   
  3. .clearfix:after {    
  4. content:".";    
  5. display:block;    
  6. height:0;    
  7. clear:both;    
  8. visibility:hidden;    
  9. }    
  10. .clearfix {   
  11. display:inline-block;   
  12. }   
  13.     
  14. .clearfix {display:block;}    
  15.     
  16.   
  17. </style>   

三、其他兼容技巧(再次啰嗦)

1, FF下给 div 设置 padding 后会导致 width 和 height 增加, 但IE不会.(可用!important解决)
2, 居中问题.
1).垂直居中.将 line-height 设置为 当前 div 相同的高度, 再通过 vertical-align: middle.( 注意内容不要换行.)
2).水平居中. margin: 0 auto;(当然不是万能)
3, 若需给 a 标签内内容加上 样式, 需要设置 display: block;(常见于导航标签)
4, FF 和 IE 对 BOX 理解的差异导致相差 2px 的还有设为 float的div在ie下 margin加倍等问题.
5, ul 标签在 FF 下面默认有 list-style 和 padding . 最好事先声明, 以避免不必要的麻烦. (常见于导航标签和内容列表)
6, 作为外部 wrapper 的 div 不要定死高度, 最好还加上 overflow: hidden.以达到高度自适应.
7, 关于手形光标. cursor: pointer. 而hand 只适用于 IE.

PS:搞公司的站,IE6,IE7,FF下这些问题头大死了,后来经过这个文章的介绍终于解决了!

贴上代码:

CSS代码

  1.   
  2. .submitbutton {   
  3.     float:left;   
  4.     width40px;   
  5.     height57px;   
  6.     margin-top24px;   
  7.     margin-right12px;   
  8. }   
  9.   
  10. *html .submitbutton {   
  11.     margin-top21px;   
  12. }   
  13.   
  14. *+html .submitbutton {   
  15.     margin-top21px;   
  16. }