Considering a grid that contains fixed size items (not my choice), and is not fixed size.
I would like to centralize the container (.grid-container
) to have same side margin no matter how many items it have and how they are placed inside container as long as they are left-aligned.
If it isn't possible to do this only with CSS how can I do using JavaScript?
It's not necessary to use twitter-bootstrap grid system like the demo code.
Here a code to illustrate: https://embed.plnkr.co/F6niiwaosnO8tr0ss4XF/
.container {
background-color: #2B3643;
}
.grid-container {
padding: 30px 30px 0 30px;
}
.grid-item-wrapper {
width: 200px;
margin-bottom: 15px;
}
.grid-item {
margin-bottom: 15px;
}
.grid-item > .item-desc {
padding: 8px;
background-color: #333333;
color: #CFCFCF;
}
<div class="container">
<div class="grid-container row">
<!-- grid items -->
</div>
</div>
<template id="tmpl_grid_item">
<div class="grid-item-wrapper col-xs-3">
<div class="grid-item">
<div class="item-picture">
<img src="http://lorempixel.com/350/200/food/" style="width: 100%;" />
</div>
<div class="item-desc">
Lorem Ipsum
</div>
</div>
</div>
</template>