Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3.0 - push element to bottom

I chose Twitter Bootstrap for quick app display layer bulding, recently I have faced problem.

I'm trying to push element to bottom of page container, but keeping it centered. Adding class .push-to-bottom { position: absolute; bottom: 50px } didn't help.

like image 390
Alan Kis Avatar asked Sep 28 '13 22:09

Alan Kis


2 Answers

If you know the dimensions of the element you want to center, you can use a margin-left being the negative value of width / 2. Like this jsFiddle example:

.push-to-bottom {
  position: absolute;
  bottom: 50px;
  left: 50%;
  margin-left: -50px;
}

#element {
  background-color: #000;
  width: 100px;
  height: 100px;
}
like image 58
thiagobraga Avatar answered Nov 14 '22 09:11

thiagobraga


Use position: absolute to get it to the bottom of the page and use the .text-center class (from Bootstrap) along with width: 100% to get it in the middle:

<div class="container">
  <div class="row force-to-bottom text-center">
    <div class="col-xs-12">
            <h1>
            <input class="btn btn-primary" type="submit" value="Save">
        </h1>

    </div>
</div>

.force-to-bottom {
  position:absolute;
  bottom: 5%;
  width: 100%;
}

Clicky here for the fiddle.

like image 31
ninjaPixel Avatar answered Nov 14 '22 08:11

ninjaPixel