-webkit-overflow-scrolling:touch;在本身沒有滾動,動態加入內容撐大後不滾動的bug
阿新 • • 發佈:2019-01-05
使用weui 1.0開發時,專案列表的div在ajax填充後,頁面無法滾動,真的傷腦筋啊!研究了好久終於解決了
When working with the overflow: scroll; attribute, the -webkit-overflow-scrolling: touch; attribute can be very useful on mobile sites. It basically changes the awkward scrolling behavior into the normal, expected behavior.
When you dynamically add content to a div with -webkit-overflow-scrolling: touch; that exceeds the div in height, it becomes broken and unscrollable
.outer {
overflow: scroll;
-webkit-overflow-scrolling: touch;
/* More properties for a fixed height ... */
}
.inner {
height: calc(100% + 1px);
}
更好的解決方案(不加div):
.outer:before { content:""; width: 1px; float: left; height: calc(100% + 1px); margin-left: -1px; display: block; } .outer:after{ content:""; width: 100%; clear: both; display: block; }