在移动设备上缩放时,如何防止网页(或div)的内容超出左右屏幕视图?例如,看看我上传的这个页面:
http://postman-canary-31048.bitballoon.com
我试图使用Div来防止内容超出页面视图,它在PC上工作得很好(尝试从台式计算机放大和缩小,并查看内容如何始终留在屏幕视图中的左侧和右侧),但当我尝试从移动设备(在我的示例中为iPhone)缩放页面时,文本在屏幕视图的左侧和右侧显示。
我如何防止这种情况发生?我希望唯一的滚动需要观看我的页面将是向上和向下,我不想我的内容(文本,图片...)会超过两边。
(请仅使用HTML和CSS,不使用Java Script)
谢谢!
发布于 2017-08-23 00:55:29
包括
<meta name="viewport" content="width=device-width,initial-scale=1">在文档的<head>中
发布于 2017-08-23 03:28:52
我更新了我的代码,它在这里:
http://fireman-suppression-84203.bitballoon.com
我添加了这行
<meta name="viewport" content="width=device-width, initial-scale=1.0">但这并没有帮助,放大iPhone仍然会导致文本在左侧和右侧溢出。
下面是完整的代码:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
div {
width:85%;
margin: auto;
border: 3px solid #73AD21;
}
</style>
</head>
<body>
<div>Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text... Just an example text...
</div>
<br>
</body>
</html>https://stackoverflow.com/questions/45822841
复制相似问题