Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to center div horizontally AND vertically in Bootstrap 3 [duplicate]

Basically I'm trying to create a similar effect as shown on this url: http://www.mediafire.com/download/asgdi8i12sgi74x/geniets+byrde.txt

That is; I want to create a div (the box) and center it horizontally and vertically at all times. I'm using Bootstrap 3. It seems like a simply task but I haven't managed to do it.

Would love it you could help me out!

like image 730
user3397240 Avatar asked Mar 16 '14 14:03

user3397240


People also ask

How do I make div center vertically and horizontally Bootstrap 3?

To center div both vertically and horizontally use flexbox utilities. See the examples. Add d-flex align-items-center justify-content-center classes to the parent element to center its content vertically and horizontally.

How do you center a div both horizontally and vertically?

You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.

How do I center a div vertically in Bootstrap 3?

Another way to vertically center is to use my-auto . This will center the element within its container. For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column. Since Bootstrap 4 .

How do I center both vertically and horizontally in CSS?

To center both vertically and horizontally, use padding and text-align: center : I am vertically and horizontally centered.


1 Answers

This is general to CSS, not bootstrap3. and we normally do it like this:

  div {
       position: absolute;
       top: 0;
       left: 0;
       bottom: 0;
       right: 0;
       margin: auto;
  }
like image 74
bingjie2680 Avatar answered Oct 21 '22 18:10

bingjie2680