我想將我的按鈕居中放置在垂直和水平方向上位於圖像上方。在圖像上的位置按鈕引導程序CSS
我該如何做到這一點與代碼? 演示:https://jsfiddle.net/bdec5ezo/
此外,一旦它到平板電腦和手機,我可以推我按鈕,所以它在左側,而不是居中?在.btn類
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
img {
max-width:100%
}
.btn {
background: rgba(0,0,0,0);
border: 1px solid #ffca00;
border-radius: 0;
color: #ffca00;
display: block;
font-size: 18px;
margin: 0 auto;
padding: 10px 55px;
text-shadow: none;
transition: all .5s ease 0s;
}
.row {
position:relative
}
button {
position:absolute;
top:40%;
left:40%
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<img src="https://placeholdit.imgix.net/~text?txtsize=141&txt=2073%C3%97563&w=2073&h=563">
<a href="http://www.google.com"><button class="btn btn-default btn-yellow" type="submit">Shop Now</button></a>
</div>
</div>
這是正確的想法,但按鈕是錯誤的方法。是否容易使其再次水平。對不起,這是我可憐的解釋。 – michaelmcgurk
是的,只要刪除這三行'-ms-transform:rotate(90deg);/* IE 9 */ -webkit-transform:rotate(90deg);/* Chrome,Safari,Opera */ transform:rotate(90deg);' – Arif
更新在這裏:https://jsfiddle.net/bdec5ezo/4/你是一個明星,阿里夫 - 非常感謝你:-) – michaelmcgurk