Skip to content

Instantly share code, notes, and snippets.

@tobynet
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobynet/137f49722ff587a57eea to your computer and use it in GitHub Desktop.
Save tobynet/137f49722ff587a57eea to your computer and use it in GitHub Desktop.
Align a button to bottom side in div
<div class="big-box">
<div class="wrap-vertical-center">
<button class="btn">Center Button</button>
</div>
</div>
/* もっとも外側のdiv */
.big-box {
/* 外側は relative の必要あり */
position: relative;
width: 100%;
height: 300px;
border: 4px dotted pink; /* for debug */
}
/* wrapper の div */
.wrap-vertical-center {
position: absolute;
width: 100%;
bottom: 15%; /* 下から基準に配置する */
border: 4px dotted gray; /* for debug */
}
/* ボタンの調整 */
.wrap-vertical-center button {
display: block;
margin: 0 auto; /* 横で中心に寄せる */
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment