CSS center content inside div
There are many ways to center any element. I listed some
- Set it's width to some value and add margin: 0 auto.
.partners {
width: 80%;
margin: 0 auto;
}
- Split into 3 column layout
.partners {
width: 80%;
margin-left: 10%;
}
- Use bootstrap layout
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">Your Content / Image here</div>
</div>
To center a div, set it's width to some value and add margin: auto.
#partners .wrap {
width: 655px;
margin: auto;
}
EDIT, you want to center the div contents, not the div itself. You need to change display property of h2
, ul
and li
to inline
, and remove the float: left
.
#partners li, ul, h2 {
display: inline;
float: none;
}
Then, they will be layed out like normal text elements, and aligned according to text-align property of their container, which is what you want.