Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
911 views
in Technique[技术] by (71.8m points)

flexbox - CSS - content not be reduced as i thought

I'm trying to make responsive content box

enter image description here

the problem is that when I reduce the size of browser a lot, the content(yellow) does not shrink at the end and just shows overflow-x.

I want it to be shrink properly until min-width..

.content_wrapper{
    max-width: 1330px;
    display:flex;
    flex-wrap: wrap;
    margin: 0 auto;
    padding: 0 20px;
}
.content_box{
    width: calc(18%);
    height: 300px;
    background: rgb(255, 255, 166);
    margin:  1%;
    
}
 @media all and (max-width: 600px){
    .content_box{
        width: 100%;
        margin-top: 0;
        margin-left: 0;
        margin-right: 0;
        margin-bottom: 15px;
    } 
    .content_wrapper{
        padding:0 15px;
        margin: 0;
    }
 }
<div class="content_wrapper">
        <div class="content_box"></div>
        <div class="content_box"></div>
        <div class="content_box"></div>
        <div class="content_box"></div>
      ~~~~

    </div>
question from:https://stackoverflow.com/questions/65897831/css-content-not-be-reduced-as-i-thought

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I looked at your code on codepen.io. You simply need to remove or your adjust your min-width attribute in for your html tag in your CSS.

For example, if you write:

html {
    min-width: 300px:
}

... your boxes will resize correctly with the screen size.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...