CSS 溢出:隐藏不适用于移动浏览器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18268300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 23:58:37  来源:igfitidea点击:

Overflow:hidden not working on mobile browser

cssmobile

提问by youaremysunshine

Im using overflow:hidden to hide my unglam div in my webpage, it works well in all web browser but not in mobile browser. Anyone can help?

我使用溢出:隐藏在我的网页中隐藏我的 unglam div,它在所有网络浏览器中运行良好,但在移动浏览器中运行良好。任何人都可以帮忙吗?

body
{
    margin: auto;
    display:block;
    overflow-x:hidden;
    overflow-y:hidden;
    height:800px;
} 

回答by Pranav Kale

Try adding following line in your html

尝试在您的 html 中添加以下行

<meta name="viewport" content="width=device-width, height=device-height">

and test on your phone. Maybe this should help.

并在您的手机上进行测试。也许这应该有所帮助。

回答by LolaRoux

Add a wrapper inside your bodytag and apply the overflow-x: hiddento that wrapper

在您的body标签内添加一个包装器并将 应用overflow-x: hidden到该包装器

回答by MattDiamant

Depending on which mobile browser you're using, overflow-xand overflow-ymay not be supported. Use overflow: hiddeninstead to cover all bases and be cross browser compatible.

取决于您使用的移动浏览器,overflow-x并且overflow-y可能不受支持。改用overflow: hidden覆盖所有基础并跨浏览器兼容。