【CSS】如何写出兼容性好的CSS

本文提供了关于CSS跨浏览器兼容性的五个实用建议,包括样式重置、图片处理、字体选择与大小设置等。此外,还介绍了如何为不同布局元素设置合适的属性值,并给出了一些关于如何确保CSS兼容性的额外提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、关于Css兼容性的5个建议:http://approache.com/blog/css-cross-browser-compatibility-tips/

1、Reset styles to make consistent look in all browsers. Sample. Note: Most JS libraries (YUI, ExtJS etc) provide reset CSS rules.
2、Do not resize images via CSS/HTML because not all browsers do it well.
3、Do not use light font on dark background because of issues in Safari that causes other issues fixing this one.
4、Use only common fonts (Arial, Georgia, Verdana etc) because of different browsers and OS’s render it differently.
5、Size font in em through the page, but initialise in % for body. I’m not exactly sure about this, but the reason is that "The ability to resize text differs amongst browsers and OS’s".
6、All layout divs that are floated should include display:inline and overflow:hidden. This is due to IE doubles margins on the float side and IE 6 layout problems.
7、Carefully clear floats using overflow:auto or overflow:hidden. Be aware of issues. See Sample().
8、Use CSS selectors subset that all of your browser support. See browser CSS selectors support.
9、Do not use PNG transparency if you need to support IE 6.

二、关于如何设置字体大小:http://alistapart.com/article/howtosizetextincss

body {
    font-size:100%;
    line-height:1.125em; /* 16×1.125=18 */
}.bodytext p {
    font-size:0.875em;
}.sidenote {
    font-size:0.75em;
}
body标签用百分数定义字体大小;其他地方用em单位定义;

三、min-height如何在ie6下实现:http://www.educity.cn/gongju/1281455.html

四、如何写出兼容大部分浏览器的CSS: http://www.cnblogs.com/LoveJenny/archive/2012/08/27/2657930.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值