/    Sign up×
Community /Pin to ProfileBookmark

Adding max-width decentralizes everything

I am using

[code]
display: flex;
flex-wrap: wrap;
[/code]

on a div. The problem is when I am trying to add max-width it decentralizes everything.
HTML code:

[code]
<div class=”t-shirts-container”>

<div class=”t-shirts-grid”>

<div class=”t-card”>
<img src=”img/t1.jpg” alt=””>
</div>
<div class=”t-card”>
<img src=”img/t2.jpg” alt=””>
</div>
<div class=”t-card”>
<img src=”img/t3.jpg” alt=””>
</div>
<div class=”t-card”>
<img src=”img/t4.jpg” alt=””>
</div>
<div class=”t-card”>
<img src=”img/t5.jpg” alt=””>
</div>

</div>
</div>
[/code]

CSS code

[code]
.t-shirts-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}

.t-card {
width: 200px;
height: 200px;
margin: 10px;
}
.t-card img {
width:100%;
}
[/code]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJun 28.2019 — Where did you apply max-width? When I do it here, everything is fine:
.t-shirts-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
max-width: 800px;
}
Copy linkTweet thisAlerts:
@codyhillauthorJun 28.2019 — @Sempervivum#1605553 There !

this is happening

[upl-image-preview url=https://www.webdeveloper.com/assets/files/2019-06-28/1561730342-553482-cfvbfgcg.png]

I have another div kinda similar but it works with margin: auto;
×

Success!

Help @codyhill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...