html - 将 <div> 与包装上的图像重叠

标签 html css image styling

我知道这个问题已经得到解答,但我很难使用之前给出的答案并将它们应用到我的代码中。

我正在制作一个包含不同图像的选项卡 Pane 。我想将图像放在右侧较浅的橙色部分,文本放在左侧。但是,此选项卡放在包装器上,这让我对索引感到困惑。

此外,当我使用 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>

最佳答案

尝试将文本向左拉,像这样;

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

关于html - 将 <div> 与包装上的图像重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654350/

相关文章:

html - 在 span 元素下划线

css - 网站上线时,鼠标悬停在图像上不会出现

c++ - 在 QTextEdit 中放置图像的几种方法

c# - 将 jpeg 图像调整为指定大小

javascript - 动态模板

JavaScript 函数未定义错误(但已定义)

javascript - jQuery - 记住触发函数

css - css 中的正则表达式失败

image - 正确理解不正确的MATLAB运算

javascript - 无法读取未定义的属性 'Elements' - 在 JS 控制台中