How to center a div with BlueprintCSS?

So, I have a div inside the container class. How to center a div so that it correctly adds white space the same to both sides, depending on the width of the div?

<body> <div class="container"> ... other stuff ... <div>center me</div> </div> </body> 
+4
source share
4 answers

You can do it as follows:

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

Usually you know the page width in range units because you define them when creating the blueprint-css file ... so you can do something like this ... "span-x" is the segment width or page in units range measurements ... the "left" floats to the left, and the "right" floats to the right ... two cancel and center the div.

 <body> <div class="container"> ... other stuff ... <div class="span-x right left last">center me</div> </div> </body> 
+1
source

Blueprint has a β€œcentered” style that you can use:

 <div class="span-10 centered">...</div> 
+1
source

An old question, I know, but you can set the margin-left and margin-right this div to auto . I believe that will do it.

-1
source

Source: https://habr.com/ru/post/1339417/


All Articles