我有简单的css动画,我使用最大宽度使水平滚动条不滚动。
元素只需在1200px中可见,不能更多也不能更少。
我试着使用max-width,但是没有效果。
section {
max-width: 1200px;
}
.box {
width: 100%;
max-width: 540px;
position: relative;
z-index: -1;
top: 0px;
transform: rotate(80deg);
left: 1500px;
}
.wave {
position: absolute;
opacity: .4;
width: 1500px;
height: 1300px;
margin-left: -150px;
margin-top: -250px;
border-radius: 43%;
}
@keyframes rotate {
from { transform: rotate(0deg); }
from { transform: rotate(360deg); }
}
.wave.-one {
animation: rotate 9000ms infinite linear;
opacity: .1;
background: #6FC4FF;
}
.wave.-two {
animation: rotate 5000ms infinite linear;
opacity: .1;
background: #319DE8;
}
.wave.-three {
animation: rotate 9500ms infinite linear;
background-color: #0087E5;
}<section>
<div class='box'>
<div class='wave -one'></div>
<div class='wave -two'></div>
<div class='wave -three'></div>
</div>
</section>
发布于 2019-08-15 01:53:09
我使用最大宽度使水平滚动条不滚动。
您需要使用overflow-x属性来隐藏水平滚动
section {
overflow-x: hidden;
width:1200px;
}发布于 2019-08-15 01:56:15
解决这个问题的一个简单方法是在body中添加overflow: hidden,如果它对您没有任何副作用
body {
overflow: hidden;
}https://stackoverflow.com/questions/57499647
复制相似问题