2

在我的网站上,我有一个显示表单的英雄单元。在表格后面,许多图像一个接一个地显示,平滑淡入淡出。

我正在尝试通过将容器 div 设置为position: relative并将保存图像的 div 设置为position: absolute. 像这样的东西:

<div class="container">
   <div class="row">
      <div class="hero"
         <div class="images">
            <img ... />
         </div>

         <div class="form">

         </div>
      </div>
   </div>
</div>

containerrow来自 Bootstrap。我的课程有以下风格:

.hero {
   position: relative;
}

.images {
   position: absolute;
}

这行得通。但是,当我开始调整浏览器窗口的大小并且响应性质开始时,imagesdiv 内的图像不再调整大小,而是保持相同的固定大小。

如何在 Bootstrap 中拥有这种类型的 div 层,同时仍然充分利用 Bootstrap 的响应特性?

4

1 回答 1

2
<div class="container">
   <div class="row">
      <div class="hero custom-image"
         <div class="form">
         </div>
      </div>
   </div>
</div>

也许你可以添加 .custom-image CSS。width以百分比设置 .custom-image 。

另一种可能性,在您的自定义 CSS 中添加媒体查询:

/* Landscape phone to portrait tablet */

@media (max-width: 767px) {
.custom-image{
width:50%;
}
}

/* Landscape phones and down */

@media (max-width: 480px) {
.custom-image{
width:50%;
}
}
于 2012-09-11T14:18:45.667 回答