html – 即使我在Chrome调试工具中更改视口,为什么网站的宽度也相同?

html – 即使我在Chrome调试工具中更改视口,为什么网站的宽度也相同?,第1张

概述我正在使用Chrome调试工具的Viewport模拟器.我发现奇怪的是,无论视口宽度如何,Chrome总是以像素为单位报告相同的宽度,并且缩放和DeviceToPixelRation(DPR)都不会更改. h1的样式设置宽度为100%,没有其他代码.我希望在视口宽度改变时宽度或DPR会改变.为什么不发生? 这是代码: <head> <meta charset="UTF-8"> <t 我正在使用Chrome调试工具的VIEwport模拟器.我发现奇怪的是,无论视口宽度如何,Chrome总是以像素为单位报告相同的宽度,并且缩放和DevicetoPixelRation(DPR)都不会更改. h1的样式设置宽度为100%,没有其他代码.我希望在视口宽度改变时宽度或DPR会改变.为什么不发生?

这是代码:

<head>    <Meta charset="UTF-8">    <Title>Title</Title>    <style>        * {            margin: 0;            padding: 0;        }        h1 {            wIDth: 100%;            background: blue        }    </style></head><body><h1>    Some header text here</h1>
解决方法 以下是 here的引用:

To attempt to provIDe the best experIEnce,mobile browsers render the
page at a desktop screen wIDth (usually about 980px,though this
varIEs across devices),and then try to make the content look better
by increasing Font sizes and scaling the content to fit the screen.
This means that Font sizes may appear inconsistent to users,who may
have to double-tap or pinch-to-zoom in order to see and interact with
the content.

这就是宽度不变的原因.浏览器只需缩小整个网页以适应屏幕.

Using the Meta vIEwport value wIDth=device-wIDth instructs the page to
match the screen’s wIDth in device-independent pixels.

这就是为什么它使用@R_404_6889@ =“vIEwport”标签调整宽度.

这似乎有效:

<Meta @R_404_6889@="vIEwport" content="wIDth=device-wIDth,initial-scale=1,shrink-to-fit=no">

有关更多信息,请阅读文档on viewport meta tag at MDN.:

The vIEwport Meta tag tells the browser that the wIDth of the screen should be consIDered the “Full WIDth” of the page. Meaning no matter the wIDth of the device you are on,whether on desktop or mobile. The website will follow the wIDth of the device the user is on.

总结

以上是内存溢出为你收集整理的html – 即使我在Chrome调试工具中更改视口,为什么网站的宽度也相同?全部内容,希望文章能够帮你解决html – 即使我在Chrome调试工具中更改视口,为什么网站的宽度也相同?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1139080.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-31
下一篇2022-05-31

发表评论

登录后才能评论

评论列表(0条)

    保存