您的位置:首页 > 其它

ie6下div的width会被padding撑开的解决思路

2014-05-21 10:15 375 查看
通过http://stackoverflow.com/questions/1210417/best-way-to-solve-the-padding-css-problem 这篇文章我们知道

可以通过改变docType来让 ie用不同的模型

HTML4 Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd" >


XHTML 1.0 Strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


XHTML 1.0 Transitional:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Your doctype must be the first thing to appear on your page. It is even before the 
<html>
 tag,
on its own line.

猜测的方法

设置该元素的box-sizing:border-box [不可行,因为ie6不支持这个属性]
反过来用非ie6的浏览器来向下兼容ie6 
设置display:inline [采用嵌套div,将内部div设置为inline或许可行]
不设置width,让padding自由撑开以达到预期的width
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: