html5 - 由于HTML头部声明的不同,造成input表单的宽度不一致,我希望可以透彻地理解为什么,跟大家一起探讨最佳的解决方案?
PHP中文网
PHP中文网 2017-04-17 11:31:32
0
2
555

正逢公司网站改版上线,由于经验的不足没有考虑到兼容之前浏览器的版本。

现在遇到如下问题:

http://example.liambaba.com/liambaba-laboratory/temp-dir/users_login_0...

http://example.liambaba.com/liambaba-laboratory/temp-dir/users_login_0...

大家可以看这两个页面的不同,是因为申明头部造成的。

我希望能详细的了解为什么,如果在这里你能慷慨的给出意见,对我来说是莫大的帮助~!

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
PHPzhong

The <!DOCTYPE> reputation of the two main pages leads to different rendering modes. This results in a different user agent stylesheet loaded by the browser.
Taking Chrome as an example, the declaration of users_login_01.html is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">, which will trigger Chrome to render in Standard mode. The corresponding <input> tag is box-sizeing. And content-box mistakenly declares non-standard users_login_02.html. Chrome will use Quirks mode for rendering, and the corresponding <!DOCTYPE> is box-sizeing. border-box

If you want to know the details, you can check the code below:

    User agent style sheet in Webkit standards mode: http://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css
  1. Webkit user agent stylesheet in mixed mode: http://trac.webkit.org/browser/trunk/Source/WebCore/css/quirks.css
Actually, the difference between the two pages is here

Peter_Zhu

The second solution of the poster was written incorrectly and should be <!DOCTYPE HTML> instead of <!DOCTYPE>. I checked the information and did not see such an abbreviation, so it was caused by the wrong writing of dtd. Mixed mode, resulting in box model errors.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template