简体   繁体   English

CSS:最大宽度不在最大宽度上

[英]CSS: max-width not on maximal width

I have simple css animation and I use max-width to make horizontal scroll bar to not scroll. 我有简单的CSS动画,并且使用max-width使水平滚动条不滚动。

Element need be visible only this what is in 1200px not more not less. 元素只需要可见,这在1200px内就不多不少。

I tried following max-width but not working. 我尝试遵循最大宽度,但无法正常工作。

 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> 

I use max-width to make horizontal scroll bar to not scroll. 我使用最大宽度使水平滚动条不滚动。

You need to use overflow-x property to hide the horizontal scroll 您需要使用overflow-x属性来隐藏水平滚动

section {
  overflow-x: hidden;
  width:1200px;
}

A simple way to solve this, if it causes no side effects to you, is to add overflow: hidden to body : 解决此问题的简单方法(如果对您没有副作用)是在body添加overflow: hidden

body {
  overflow: hidden;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM