0

The button is slightly off-center vertically. How to center it?

https://jsfiddle.net/toxh2r46/

<body>
<br><br>
<div class="well">well <button type="button" class="btn btn-primary" style="float:right;">Visit Page</button></div>
hvs
  • 518
  • 1
  • 5
  • 21
  • I don't have time to make a custom example at the moment, but [take a look here](http://jsfiddle.net/turbopipp/n62s5pjb/). It might help you along the way while you wait for an answer. :) – turbopipp Oct 27 '15 at 16:55
  • Possible duplicate of [CSS Vertical align does not work with float](http://stackoverflow.com/questions/11718134/css-vertical-align-does-not-work-with-float) – Luizgrs Oct 27 '15 at 18:25

2 Answers2

2

You could also use Bootstraps Media Object component for this. See example Snippet.

body {
  padding-top: 50px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="well">
    <div class="media">
      <div class="media-body">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College.</div>
      <div class="media-right media-middle">
        <button type="button" class="btn btn-primary">Visit Page</button>
      </div>
    </div>
  </div>
</div>
vanburen
  • 21,502
  • 7
  • 28
  • 41
1

One way is to use this solution:

HTML:

<div class="container">
  <div class="well">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea fuga corporis accusantium, molestiae aspernatur. Cumque accusamus porro modi sequi voluptatem architecto voluptatum saepe, quaerat quisquam. Animi eligendi dicta mollitia cupiditate! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae architecto harum quidem dignissimos fugit iste culpa debitis ab suscipit dolores! Odio, at vitae, eius ullam fugit sed laborum facere sequi?
    <button type="button" class="btn btn-primary" style="float:right;">Visit Page</button>
  </div>
</div>

CSS:

body {
    margin: 100px 0;
}
.well {
    position: relative;
    padding-right: 120px;
}
button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 15px;
}

UPDATED JSFIDDLE

max
  • 8,632
  • 3
  • 21
  • 55