【问题标题】:how to force the horizontal space (responsive)如何强制水平空间(响应式)
【发布时间】:2020-12-03 23:28:49
【问题描述】:

我正在尝试使我的网站具有响应性,在移动版上,右侧有一个水平空间,我想强制它消失。 (PS:我的 div 上没有宽度或高度)

【问题讨论】:

标签: css mobile responsive-design responsive mobile-website


【解决方案1】:

隐藏水平空间的最简单方法是将其添加到您的body

body {
    overflow-x: hidden;
}

这是一个简单的例子:

body {
  overflow-x: hidden;
}

div {
  width: 120vw;
  height: 10px;
  background-color: #f00;
}
<!DOCTYPE html>
<html>
  <body>
    <div></div>
  </body>
</html>

您可以看到溢出父容器的所有内容(在这种情况下为body)将被隐藏。

【讨论】:

    猜你喜欢
    • 2020-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-01
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多