<!DOCTYPE html>
<html>
<head>
<style>
.d1 {
background-color: lightblue;
display: flex;
overflow: scroll;
padding: 10px;
}
.d2 {
background-color: yellow;
margin: 5px;
}
</style>
</head>
<body>
<div class="d1">
<div class="d2">111111111111111111111</div>
<div class="d2">111111111111111111111</div>
<div class="d2">111111111111111111111</div>
<div class="d2">111111111111111111111</div>
</div>
</body>
</html>
在这个简单的示例中,我在父级padding
上同时使用了div
,在margin
上同时使用了child
,但是容器的最右边没有padding
或margin
...如何我能解决这个问题吗? Ty
尝试一下
我想您要在滚动条出现时保留浅蓝色填充。您必须将滚动容器和填充容器分开才能实现此目的。