【问题标题】:How can I put the second image and the button(bellow it) align?我怎样才能把第二张图片和按钮(下面)对齐?
【发布时间】:2020-07-17 14:23:10
【问题描述】:

#services {
  background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(imagens/imagemdefundo1.jpg);
  background-size: cover;
  background-position: center;
  color: #efefef !important;
  background-attachment: fixed;
  padding-top: 50px;
  padding-bottom: 50px;
}

#services h1 {
  text-align: center;
  color: #efefef !important;
  padding-bottom: 10px;
}

#services h1::after {
  content: '';
  background: #efefef;
  display: block;
  height: 3px;
  width: 420px;
  margin: 20px auto 5px;
}

.image2 img {
  width: 400px;
  margin: 50px auto 60px;
  float: right;
}

.image1 img {
  width: 350px;
  float: left;
}

.image2 button {
  margin-left: 20px;
  align-items: right;
}

.image1 button {
  margin-top: 150px;
  margin-left: -230px;
}
<section id="services">
  <div class="container">
    <h1>Serviços de entrega</h1>
    <div class="row services">
      <div class="image1">
        <img src="imagens/glovoteste.jpg.png">
        <button type="button" class="btn btn-primary">Encomendar</button>
      </div>
      <div class="image2">
        <img src="imagens/ubereatstest.jpg.png">
        <button type="button" class="btn btn-primary">Encomendar</button>
      </div>
    </div>
  </div>
</section>

【问题讨论】:

    标签: html css image button


    【解决方案1】:

    您需要像下面的代码一样使用 Bootstrap 的网格系统 (https://getbootstrap.com/docs/4.0/layout/grid/)。

    注意在图像.jpg.png 上只使用一种格式。

    #services {
      background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(imagens/imagemdefundo1.jpg);
      background-size: cover;
      background-position: center;
      color: #efefef !important;
      background-attachment: fixed;
      padding-top: 50px;
      padding-bottom: 50px;
    }
    
    #services h1 {
      text-align: center;
      color: #efefef !important;
      padding-bottom: 10px;
    }
    
    #services h1::after {
      content: '';
      background: #efefef;
      display: block;
      height: 3px;
      width: 420px;
      margin: 20px auto 5px;
    }
    
    .image2 img {
      width: 100%;
      float: right;
    }
    
    .image1 img {
      width: 100%;
      float: left;
    }
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    
    <section id="services">
      <div class="container">
        <h1>Serviços de entrega</h1>
        <div class="row services">
          <div class="image1 col-6">
            <img src="https://cdn.pixabay.com/photo/2016/04/04/14/12/monitor-1307227_1280.jpg">
            <button type="button" class="btn btn-primary">Encomendar</button>
          </div>
          <div class="image2 col-6">
            <img src="https://cdn.pixabay.com/photo/2016/04/04/14/12/monitor-1307227_1280.jpg">
            <button type="button" class="btn btn-primary">Encomendar</button>
          </div>
        </div>
      </div>
    </section>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 1970-01-01
      • 2014-01-28
      • 1970-01-01
      • 2013-12-26
      • 2010-10-10
      相关资源
      最近更新 更多