-1

I have four div blocks and I want to Centre the Horizontally, they keep stacking under each other.. any ideas how I can do this.

<div class="container">
   <div style="width:78%; margin:0 auto;">
    <div class="block">1. name of the company</div>
    <div class="block">2. name of the company</div>
    <div class="block">3. name of the company</div>
    <div class="block">4. name of the company</div>
</div>

2 Answers2

0

From what I understand is that you want the blocks next to each other.

Is this what you are looking for? Demo.

HTML

<div class="container">
    <div class="block-wrapper">
        <div class="block">1. name of the company</div>
        <div class="block">2. name of the company</div>
        <div class="block">3. name of the company</div>
        <div class="block">4. name of the company</div>
    </div>
</div>

CSS

.block-wrapper {
    width: 78%;
    text-align: center;
}
.block {
    display: inline-block;
}
Ex-iT
  • 1,479
  • 2
  • 12
  • 20
0

You can try using inline-block.

http://jsfiddle.net/8Qk5K/

display: inline-block;

This type of display value makes each block take up as much horizontal space as it needs (or it is given to) . Works best with percentage values if you want it responsive.

Also, I recommend using http://jsfiddle.net for demos. It is much easier for everybody to understand!

Good luck!

Hristo Georgiev
  • 2,499
  • 1
  • 16
  • 23