Reputation: 33674
I have the following js-fiddle. It's basically just a div
that has a bunch of square child elements. The issue is that the div
doesn't always stay centered. I've already set the following CSS
:
.boutique-grid {
text-align: center;
margin-left: auto;
margin-right: auto;
}
I am not sure why it's not centering the child element div's. Any idea?
Upvotes: 0
Views: 101
Reputation: 15709
Set width of div
and image
.
.boutique-grid {
width: 300px;
text-align: center;
margin-left: auto;
margin-right: auto;
}
Upvotes: 0
Reputation: 21
This is what the spec says about float
:
The element generates a block box that is floated to the left. Content flows on the right side of the box, starting at the top (subject to the 'clear' property).
This is why .boutique-grid-column
becomes block when float
is specified and ignores text-align
.
Upvotes: 0
Reputation: 1842
Remove float:left;
and this will work fine, you already have display:inline-block;
set so no need to float the element.
Upvotes: 0
Reputation: 2378
.boutique-grid {
text-align: center;
}
.boutique-grid-column {
...
margin: 0 auto;
}
Upvotes: 0
Reputation: 5847
The boutique-grid
is centered, but it's 100% wide. You can set a width to for example, 710px;
.boutique-grid {
overflow: hidden;
width: 710px;
}
Upvotes: 0
Reputation: 1652
Remove float left from your .boutique-grid-column class. It will solve the issue.
Upvotes: 3