使用包装器上的图像重叠<div>

时间:2017-12-05 13:04:55

标签: html css image styling

我知道这个问题已经得到解答,但我使用之前给出的答案并将其应用到我的代码中时遇到了极大的困难。

我正在创建一个包含不同图像的标签窗格。我想把图像放在右边较浅的橙色部分,左边是文字。但是,此选项卡被放置在包装器上,这使我对索引感到困惑。

此外,当我使用XXAMP时,所有在不考虑包装器的情况下工作的解决方案都不起作用。

以下是我目前所做的并适用于描述:

这是我到目前为止的代码:

body {
  background-color: #FFF;
  background-image: url(../media/style/background.jpg);
  font-family: helvetica;
  background-repeat: no-repeat;
  background-size: cover;
  overflow-x: hidden;
  background-attachment: fixed;
}

#wrapper img {
  width: 80%;
  height: 60%;
}

#wrapper {
  width: 900px;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 20px;
  margin-top: 20;
  margin-right: auto;
  margin-bottom: 20;
  margin-left: auto;
  height: auto;
  border: medium none #9C0;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.images {
  position: relative;
  text-align: center;
}

.tab-content {
  width: 825px;
  border-bottom: 2px solid white;
  border-right: 2px solid white;
  border-left: 2px solid white;
  border-top: 2px solid white;
  padding: 13px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: right;
}

.nav-tabs {
  margin-bottom: 0;
  width: 805px;
}

.tab-content {
  display: block;
  background-color: rgba(245, 172, 64, 0.9);
  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 50%, #F4B350 50%);
  min-height: 300px;
  z-index: -1;
}

.tab-content img {
  position: relative;
  width: 58vw;
  height: 42vw;
}

.container a {
  background-color: rgba(245, 172, 64, 0.9);
  color: black;
}

.tab-content p {
  font-size: 15px;
}

.tab-content h3 {
  font-size: 28px;
}

#tab1 h3 p {
  background-color: white;
}
<!DOCTYPE html>
<html>

<head>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <meta charset="UTF-8" />
  <title>Hanler Products - Home</title>
</head>

<body>

  <!-- TAB -->

  <div class="container">
    <ul class="nav nav-tabs">
      <li class="active"><a data-toggle="tab" href="#tab1">Upright Towbar Caddy</a></li>
      <li><a data-toggle="tab" href="#tab2">Upright Trailer lid Caddy</a></li>
      <li><a data-toggle="tab" href="#tab3">Park Stand</a></li>
      <li><a data-toggle="tab" href="#tab4">Gates / Burglar Bars / Security Gates</a></li>
      <li><a data-toggle="tab" href="#tab5">Fences</a></li>
    </ul>

    <div class="tab-content">
      <div id="tab1" class="tab-pane fade in active">
        <div class="box">
          <h3>Upright Towbar Caddy</h3>
          <p>Ideal for short trips to school and back.</p>
        </div>
        <img src="media/style/slider/UTC.jpg" alt="Upright Towbar Caddy">
      </div>
      <div id="tab2" class="tab-pane fade">
        <h3>Upright Trailer lid Caddy</h3>
        <p>Now, taking your cycles on holiday, is a breeze.</p>
        <img src="media/style/UTC.jpg" alt="Upright Trailer lid Caddy" />
      </div>
      <div id="tab3" class="tab-pane fade">
        <h3>Park Stand</h3>
        <p>Ideal for parking bikes at shops, schools and at shopping malls.<br/>The parkstand could prevent damage to vehicles <br/> in parking areas.<br/>The bike could also be chained to be stand <br/> to protect it from being stolen.</p>
      </div>
      <div id="tab4" class="tab-pane fade">
        <h3>Gates / Burglar Bars / Security Gates</h3>
        <p>Custom security bars to keep you and your belongings safe.</p>
      </div>
      <div id="tab5" class="tab-pane fade">
        <h3>Fences</h3>
        <p>Custom fencing for your home and/or business.</p>
      </div>
    </div>
  </div>
</body>

</html>

1 个答案:

答案 0 :(得分:0)

尝试将文字拉到左边,就像这样;

<div class="tab-content">
        <div id="tab1" class="tab-pane fade in active">
          <div class="box pull-left">