gpt4 book ai didi

html - 在图像上放置按钮 Bootstrap CSS

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:38 24 4
gpt4 key购买 nike

我想将按钮垂直和水平放置在图片的中央。

如何使用代码执行此操作? 演示: https://jsfiddle.net/bdec5ezo/

此外,一旦它到达平板电脑和手机,我可以按下按钮使其位于左侧而不是居中吗?

/* 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>

最佳答案

试试这个 FIDDLE

/* 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;
-ms-transform: rotate(90deg); /* IE 9 */
-webkit-transform: rotate(90deg); /* Chrome, Safari, Opera */
transform: rotate(90deg);
}

.row {
position:relative
}

button {
position:absolute;
top:40%;
left:38%

}
@media (max-width:768px){
button {left:0%}
}
<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>

关于html - 在图像上放置按钮 Bootstrap CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38686621/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com