sameold
sameold

Reputation: 19252

How to accomplish center alignment with float

I'm trying to center all 3 divs. Is there a way to get this done without creating a wrap around div2 and div3.

               div1  | div2 |  div3
------------------------------------------------

Upvotes: 0

Views: 52

Answers (1)

Martin Turjak
Martin Turjak

Reputation: 21234

You could try something like this, as body will most probably be present:

<body>
    <div class="centered" id="a">A</div>
    <div class="centered" id="b">B</div>
    <div class="centered" id="c">C</div>
</body>

CSS:

body {
    text-align: center;
}

.centered {
    display: inline-block;
}

jsFiddle

Upvotes: 2

Related Questions