Home  >  Article  >  Web Front-end  >  width:1050px在Chrome,Firefox,IE下的宽度居然是不一样的?_html/css_WEB-ITnose

width:1050px在Chrome,Firefox,IE下的宽度居然是不一样的?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:41:291463browse

同样的机器,就一个宽度设置,居然在3个浏览器下显示出来宽度是不一样的.IE8下最长,Firefox次之。
  因为要放一个图片,图片的大小是1050px,在Chrome下效果是最好的,其它浏览器由于缩放了,效果不是很清晰,
  请问该如何解决?

  <div style="width:1050px;height:30px;background-color: blue"></div>


回复讨论(解决方案)

margin padding border之类的全部赋值0写死

那就兼容浏览器呗。

1楼正解,因为各浏览器解析标签时有个默认的属性,margin、padding和border是最常见的,全部赋值为0可以避免出现问题。

会不一样的,有的会浏览把border算到宽度中,有的则不会

常备基础代码。。。。

*{border:0;padding:0;margin:0;text-decoration:none;}

新人,来刷刷题~看到五楼好几次啦~话说你好像很喜欢那个表情啊

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn