Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
920 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...