1

I have a div with two inner child divs, im using flexbox so that they wrap underneath eachother on smaller screens.

They wrap fine, but the parent's div doesnt shrink with a max-width on it. leaving my boxshadow full sized.

any help appreciated, here's the codepen.

https://codepen.io/Middi/pen/JvLNEZ

HTML

<!--======== SOCIAL SECTION ========-->

<section id="social" class="social">
    <div class="social-container">
        <div class="social-container-half">
            <div class="insta-header">
                <h4 class="h4-display">INSTAGRAM</h4>
            </div>
        </div>
        <div class="social-container-half">
            <div class="twitter-header">
                <h4 class="h4-display">TWITTER</h4>
            </div>
        </div>
    </div>
</section>

CSS

.social-container {
    max-width: 1150px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 4px 4px 10px 2px rgba(black, 0.7); 
    position: absolute;
    top: 30px;
    background-color: yellow;
    left: 0;
    right: 0;
}

.social-container-half {
    box-sizing: border-box;
    width: 575px;
    background-color: white;
    border: 1px solid red;
}
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
Middi
  • 343
  • 1
  • 3
  • 12

1 Answers1

1

You're giving it an absolute value with the width: 575px (pixels are absolute AKA they don't shrink) you can give it a width: 30% and works just fine

UPDATED ANSWER

I think this is what you want: https://codepen.io/arpanpatel/pen/RyMVmN

Middi
  • 343
  • 1
  • 3
  • 12
manAbl
  • 506
  • 5
  • 21
  • Yeah, the inner divs want to be 575px, its the outer div that needs to shrink when they drop down, the yellow div is not shrinking. – Middi May 10 '18 at 13:39
  • updated answer @Middi – manAbl May 10 '18 at 13:54
  • yes https://codepen.io/arpanpatel/pen/RyMVmN is what I'm after. I'm guessing theres no way to do it without a media-query which is a shame. Thanks for your help mate! – Middi May 10 '18 at 13:56