【问题标题】:Pseudo element ::before causing horizontal scroll bar伪元素 ::before 导致水平滚动条
【发布时间】:2016-06-25 17:55:59
【问题描述】:

我在摆脱水平滚动条时遇到了问题。我的设计设置具有正确的尺寸和定位,但我只想隐藏 ::before 图像元素技巧的溢出。

你可以在这里看到我的意思: http://192.99.37.125/~uptownlounge/

我尝试添加 overflow-x: hidden;到 body 元素,但它在移动设备上被搞砸了。还有其他想法吗?

【问题讨论】:

  • 发布重现问题的 html/CSS 的最小部分

标签: css overflow pseudo-element pseudo-class


【解决方案1】:

对于带有此选择器的移动设备,请使用width:100%;:#dots-dark::before{}

那么overflow的问题就解决了。

#dots-dark::before {
   background-color: transparent;
   background-image: url("https://s3.amazonaws.com/webdiner/dots-red-top-arrow.png");
   background-position: top center;
   background-repeat: no-repeat;
   background-size: auto;
   position: absolute;
   content: " ";
   height: 131px;
   display: inline;
   width: 100%;
   left: 127%;
   top: -131px;
   margin-left: -804px; 
}

【讨论】:

  • 那行不通。它会破坏绝对位置的居中。
  • 好的,可以试试小背景图片,根据设备宽度减小宽度吗?
猜你喜欢
  • 1970-01-01
  • 2012-11-14
  • 2018-06-20
  • 2012-12-18
  • 2013-11-05
  • 2017-11-25
  • 2010-11-18
  • 2015-10-06
  • 2021-07-15
相关资源
最近更新 更多