How to center a div with BlueprintCSS?

3.2k views Asked by At

So I have div within the container class. How do I center the div, so that it properly adds empty space equally to both sides, depending on the width of the div?

<body>
  <div class="container">
    ... other stuff ...
    <div>center me</div>
  </div>
</body>
4

There are 4 answers

0
Fizz On

Old question, I know but you could set the margin-left and margin-right of that div to auto. I believe that would do it.

0
Ferruccio On

Blueprint has a "centered" style you can use:

<div class="span-10 centered">...</div>
0
Mike Pennington On

Normally you know the width of the page in span units because you define them when you build your blueprint-css file... so you could do something like this... "span-x" is the width of the segment or page in span units... "left" floats left, and "right" floats right... the two cancel and center the div.

<body>
  <div class="container">
    ... other stuff ...
    <div class="span-x right left last">center me</div>
  </div>
</body>
0
gtrak On

You can do it like this:

<div class="span-6 last prepend-9 append-9">contents</div>