elu*_*nap 6 html css twitter-bootstrap twitter-bootstrap-3
我有一个图像,我需要在其上放一个按钮,问题是我不知道如何放置按钮并在浏览器变小时自动重新调整大小和位置,现在我已经按下了按钮,但是当我重新调整浏览器的大小按钮移动时,我尝试使用css中的百分比购买不起作用,我该怎么办?
<div id="discover" class="container-fluid">
<div class="row-fluid"> 
  <div class="col-lg-12 col-sm-12 col-xs-12 col-md-12 withimg">
    <img id="discoveryour" src="img/x.png" class="img-responsive">
  </div>  
</div>
<div class="row-fluid"> 
  <div id="bttnimg" class="col-lg-12 col-sm-12 col-xs-12 col-md-12">
<form id="start" method="post" action="x.php">
<button class="btn-primary">text</button>
</form> 
</div>
</div>
</div> 
CSS:
  .withimg {
  width: 100%;
  overflow:hidden;
  padding: 0px;
  margin: 0px;
 }
  #discover{
  position: relative;  
 }
#bttnimg{
float: left;
position: absolute;
left: 62%;
top: 25%;
max-width: 750px;
 }
ter*_*rse 21
啊,好老"如何在响应式图像上叠加东西 - 响应"问题.
有点棘手,但也不算太糟糕.棘手的一点是如何在图像大小改变时使东西的垂直位置响应.
不要害怕,这是一个简单的方法:
HTML:
<div class="img-wrapper">
    <img class="img-responsive" src="http://lorempixel.com/output/people-q-c-1200-400-4.jpg">
    <div class="img-overlay">
      <button class="btn btn-md btn-success">Button</button>
    </div>
</div>
CSS:
.img-wrapper {
  position: relative;
 }
.img-responsive {
  width: 100%;
  height: auto;
}
.img-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
}
.img-overlay:before {
  content: ' ';
  display: block;
  /* adjust 'height' to position overlay content vertically */
  height: 50%;
}
该img-overlay:before伪类通过推动手柄垂直定位作业img-overlay从图像的顶部DIV下来.在此示例中,按钮的顶部将始终为图像的50%(height: 50%如果您希望按钮更高或更低,则更改属性).
要使按钮大小响应窗口宽度,可以为按钮创建新类.我们称之为btn-responsive(这btn-md在上面的例子中取代).然后使用@media查询调整btn-responsive不同窗口宽度的属性.像这样的东西:
.btn-responsive {
  /* matches 'btn-md' */
  padding: 10px 16px;
  font-size: 18px;
  line-height: 1.3333333;
  border-radius: 6px;
}
@media (max-width:760px) { 
    /* matches 'btn-xs' */
    .btn-responsive {
        padding: 1px 5px;
        font-size: 12px;
        line-height: 1.5;
        border-radius: 3px;
    }
}
等等其他屏幕宽度.
| 归档时间: | 
 | 
| 查看次数: | 20790 次 | 
| 最近记录: |