首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >-webkit-overflow-scrolling:触摸;在子元素中设置背景时,忽略边框半径

-webkit-overflow-scrolling:触摸;在子元素中设置背景时,忽略边框半径
EN

Stack Overflow用户
提问于 2018-01-15 15:22:17
回答 1查看 523关注 0票数 1

safari上有一个奇怪的现象:当子元素有背景时,父元素的border-radius不起作用。

删除-webkit-overflow-scrolling: touch;时,一切正常。

在safari中设置-webkit-overflow-scrolling: touch;会发生什么?如何在保留-webkit-overflow-scrolling: touch;的同时防止出现奇怪的现象?

代码语言:javascript
复制
html,
body {
  background: red;
}

* {
  padding: 0;
  margin: 0;
}

.main {
  height: 250px;
  width: 250px;
  margin: 10px;
  overflow: scroll;
  border-radius: 20px;
  background: green;
  -webkit-overflow-scrolling: touch; //ios平滑滚动
}

ul li {
  list-style-type: none;
}

li:nth-child(even) {
  background: gray;
}
代码语言:javascript
复制
<div class="main">
  <ul>
    <li>This covers miscellaneous DOM extensions used by Safari in macOS and iOS. These extensions include DOM touch events for processing gestures for devices that have a touch screen and visual effects that support 2D and 3D transforms, animation, and transitions.
      Most of the classes described in this reference are Apple extensions that may also be proposed W3C standards.</li>
    <li>This covers miscellaneous DOM extensions used by Safari in macOS and iOS. These extensions include DOM touch events for processing gestures for devices that have a touch screen and visual effects that support 2D and 3D transforms, animation, and transitions.
      Most of the classes described in this reference are Apple extensions that may also be proposed W3C standards.</li>
    ...
  </ul>
</div>

EN

回答 1

Stack Overflow用户

发布于 2018-01-15 17:20:31

我在同事的帮助下解决了这个问题,如下所示:

代码语言:javascript
复制
    .main {
        margin: 10px;
        background: green;
        overflow: scroll;
        border-radius: 20px;
    }
    .main .wrapper {
        height: 250px;
        overflow: scroll;
        border-radius: 20px;
    }

我在滚动区域(.main)和滚动内容(Ul)之间添加了一个包装元素,然后将包装高度、溢出和边框半径设置为与滚动区域(.main)相同。但是当set -webkit-overflow-scrolling as touch时会发生什么呢?期待您的答复。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48258505

复制
相关文章

相似问题

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