Archive for the ‘css’ Category

CSS之兼容浏览器篇

Posted in css by chisdy on September 8th, 2007 1,845Views and Add Comments »

IE box-model这个臭名昭著的bug存在于IE6/Win以前的每一只版本,这个虫子直到tantak发布了流传最为广泛的那个hack才开始被驯服

http://www.tantek.com/CSS/Examples/boxmodelhack.html

IE5.X/win对box-model的解析是一样的,他们认为width包括了边框(border)和补白(padding),幸运的是这个情况在IE6中有了好转
但是IE6在向后兼容的同时也包容了以前的错误,IE6其实有两个核心,在旧的页面前他仍旧表现出对错误的宽容,只有在文档中严格地加上文档类型(DOCTYPE)声明,IE6才能够接受正确的box-model
所以,tantak的hack必须和正确的DOCTYPE同时包含在文档中才能够正常工作

div.content {
width:400px; //这个是错误的width,所有浏览器都读到了
voice-family: “\”}\”"; //IE5.X/win忽略了”\”}\”"后的内容
voice-family:inherit;
width:300px; //包括IE6/win在内的部分浏览器读到这句,新的数值(300px)覆盖掉了旧的
}
html>body .content { //html>body是CSS2的写法
width:300px; //支持CSS2该写法的浏览器有幸读到了这一句
}

Continue reading »

IE与Firefox的CSS兼容–注意事项

Posted in css by chisdy on September 8th, 2007 1,967Views and Add Comments »

1、float的div一定要闭合。

例如:(其中floatA、floatB的属性已经设置为float:left;)

< #div id="floatA" >
< #div id="floatB" >
< #div id="NOTfloatC" >

这里的NOTfloatC并不希望继续平移,而是希望往下排。
这段代码在IE中毫无问题,问题出在FF。原因是NOTfloatC并非float标签,必须将float标签闭合。

< #div class="floatB">
< #div class="NOTfloatC">

之间加上

< #div class="clear">

这个div一定要注意声明位置,一定要放在最恰当的地方,而且必须与两个具有float属性的div同级,之间不能存在嵌套关系,否则会产生异常。 Continue reading »

IE与Firefox的CSS兼容–常见兼容问题

Posted in css by chisdy on September 8th, 2007 1,861Views and Add Comments »

CSS对浏览器器的兼容性具有很高的价值,通常情况下IE和Firefox存在很大的解析差异,这里介绍一下兼容要点。

常见兼容问题:

1.DOCTYPE 影响 CSS 处理
2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行
3.FF: body 设置 text-align 时, div 需要设置 margin: auto(主要是 margin-left,margin-right) 方可居中
4.FF: 设置 padding 后, div 会增加 height 和 width, 但 IE 不会, 故需要用 !important 多设一个 height 和 width
5.FF: 支持 !important, IE 则忽略, 可用 !important 为 FF 特别设置样式
6.div 的垂直居中问题: vertical-align:middle; 将行距增加到和整个DIV一样高 line-height:200px; 然后插入文字,就垂直居中了。缺点是要控制内容不要换行
7.cursor: pointer 可以同时在 IE FF 中显示游标手指状, hand 仅 IE 可以
8.FF: 链接加边框和背景色,需设置 display: block, 同时设置 float: left 保证不换行。参照 menubar, 给 a 和 menubar 设置高度是为了避免底边显示错位, 若不设 height, 可以在 menubar 中插入一个空格。 Continue reading »

Page 4 of 41234