首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何防止div的内容在移动端缩放时超出屏幕视图?

问如何防止div的内容在移动端缩放时超出屏幕视图?
EN

Stack Overflow用户
提问于 2017-08-23 00:30:17
回答 2查看 174关注 0票数 1

在移动设备上缩放时,如何防止网页(或div)的内容超出左右屏幕视图?例如,看看我上传的这个页面:

http://postman-canary-31048.bitballoon.com

我试图使用Div来防止内容超出页面视图,它在PC上工作得很好(尝试从台式计算机放大和缩小,并查看内容如何始终留在屏幕视图中的左侧和右侧),但当我尝试从移动设备(在我的示例中为iPhone)缩放页面时,文本在屏幕视图的左侧和右侧显示。

我如何防止这种情况发生?我希望唯一的滚动需要观看我的页面将是向上和向下,我不想我的内容(文本,图片...)会超过两边。

(请仅使用HTML和CSS,不使用Java Script)

谢谢!

EN

回答 2

Stack Overflow用户

发布于 2017-08-23 00:55:29

包括

代码语言:javascript
复制
<meta name="viewport" content="width=device-width,initial-scale=1">

在文档的<head>中

票数 0
EN

Stack Overflow用户

发布于 2017-08-23 03:28:52

我更新了我的代码,它在这里:

http://fireman-suppression-84203.bitballoon.com

我添加了这行

代码语言:javascript
复制
<meta name="viewport" content="width=device-width, initial-scale=1.0">

但这并没有帮助,放大iPhone仍然会导致文本在左侧和右侧溢出。

下面是完整的代码:

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45822841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档