我想将我的按钮居中放置在垂直和水平方向上位于图像上方。在图像上的位置按钮引导程序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