5

Original

I am new to CSS, how i can make the div stay at the center of the page like this?

Desired

<div class="container">
    <div class="row">
        <div class="col-md-2">

        </div>
        <div class="col-md-8 center-block">
            <img class="img-responsive" id="MainCharacter" src="../Images/test_character.png" />
        </div>
        <div class="col-md-2">

        </div>
    </div>
</div>
BernardWong
  • 77
  • 1
  • 6

1 Answers1

3

Use CSS similar to this:

.container{
  position: relative;
}

.row {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

A possible problem is that this code will apply to all .container's and .rows. You could add an id to them and select it using that id.

Chris Happy
  • 7,088
  • 2
  • 22
  • 49