易截截图软件、单文件、免安装、纯绿色、仅160KB

DIV+CSS设计时浏览器兼容性问题

在这种浏览器下显示正常,在另一种下就乱了,我们在编写CSS的时候会很恼火,刚修复了这个浏览器的问题,结果另外一个浏览器却出了新问题。

-
  
什么是浏览器兼容:当我们使用不同的浏览器(Firefox IE7
IE6)访问同一个网站,或者页面的时候,会出现一些不兼容的问题,在这种浏览器下显示正常,在另一种下就乱了,我们在编写CSS的时候会很恼火,刚修复
了这个浏览器的问题,结果另外一个浏览器却出了新问题。好吧,我服了行吧,那我就利用你们的不兼容各写一段css,让他们各执行各的,呵呵。 
一、!important (功能有限) 
随着IE7对!important的支持, !important 方法现在只针对IE6的兼容.(注意写法.记得该声明位置需要提前.) 
例如: 
#example { 
width: 100px !important; /* IE7+FF */ 
width: 200px; /* IE6 */ 

二、CSS HACK的方法(新手可以看看,高手就当路过吧) 
首先需要知道的是: 
所有浏览器 通用 height: 100px; 
IE6 专用 _height: 100px; 
IE7 专用 *+height: 100px; 
IE6、IE7 共用 *height: 100px; 
IE7、FF 共用 height: 100px !important; 
例如: 
#example { height:100px; } /* FF */ 
* html #example { height:200px; } /* IE6 */ 
*+html #example { height:300px; } /* IE7 */ 
下面的这种方法比较简单 
举几个例子: 
1、IE6 - IE7+FF 
#example { 
height:100px; /* FF+IE7 */ 
_height:200px; /* IE6 */ 

其实这个用上面说的第一种方法也可以 
#example { 
height:100px !important; /* FF+IE7 */ 
height:200px; /* IE6 */ 

2、IE6+IE7 - FF 
#example { 
height:100px; /* FF */ 
*height:200px; /* IE6+IE7 */ 

3、IE6+FF - IE7 
#example { 
height:100px; /* IE6+FF */ 
*+height:200px; /* IE7 */ 

4、IE6 IE7 FF 各不相同 
#example { 
height:100px; /* FF */ 
_height:200px; /* IE6 */ 
*+height:300px; /* IE7 */ 

或: 
#example { 
height:100px; /* FF */ 
*height:300px; /* IE7 */ 
_heigh


相关文档:

css中 display属性和visibility的区别

display Property Values
ValueDescription
none
The element will generate no box at all
block
The element will generate a block box (a line break before and after the element)
inline
The element will generate an inline box (no line break before or after the element). This is default
inline-blo ......

全面兼容IE6/IE7/IE8/FF的CSS HACK写法

margin-bottom:40px;       /*ff的属性*/
margin-bottom:140px\9;    /* IE6/7/8的属性 */
color:red\0;              /* IE8支持 */
*margin-bottom:450px;     /*IE6/7的属性*/ ......

关于css的界面问题:

自己总结的心得:
1:在css设计中,当图片不够宽时,这时可以考虑使用背景颜色(与该图片相似的颜色)来补充。
2,在css设计中,可以使用图片的背景色向网页的背景色过渡
如图:
具体参照《精通JavaScript+Jquery》3-20.html ......

CSS在IE6,IE7,FIREFOX中的区别

第一种,是CSS HACK的方法
height:20px; /*For Firefox*/
*height:25px; /*For IE7 & IE6*/
_height:20px; /*For IE6*/
注意顺序。
这样也属于CSS HACK,不过没有上面这样简洁。
#example { color: #333; } /* Moz */
* html #example { color: #666; } /* IE6 */
*+html #example { color: #999; } /* IE7 */ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号