html - 如何将 Bootstrap 轮播保存在容器中?

标签 html css twitter-bootstrap

我似乎在使用 Bootstrap 轮播时遇到困难,它似乎在容器/行之外“中断”。我不是 100% 确定我可能需要提供什么样的信息(第一次在这里发帖寻求帮助)但这里是一个屏幕截图,后面是代码(只是一个典型的 Bootstrap 轮播调整大小)

错误截图

Screenshot of error

.project01-carousel {
 width:640px;
 height:360px;
 }

  <div class="col-sm-4">
  <section class="project01-carousel halfheight">
   <section class="project-carousel-wrap halfheight">

<!-- Carousel -->
<div class="project-carousel owl-carousel owl-nav-sticky-wide">

  <div class="project-carousel-item project-01-carousel-item-01 halfheight 
  text-center">
  <img src="admin/uploaded_image/terrain_renders/<?php echo $row['render1']; 
   ?>">
  </div>
  <div class="project-carousel-item project-01-carousel-item-02 halfheight 
  text-center">
  <img src="admin/uploaded_image/terrain_renders/<?php echo $row['render2']; 
   ?>">
  </div>
  <div class="project-carousel-item project-01-carousel-item-03 halfheight 
  text-center">
  <img src="admin/uploaded_image/terrain_renders/<?php echo $row['render3']; 
   ?>">
  </div>
  <div class="project-carousel-item project-01-carousel-item-04 halfheight 
   text-center">
  <img src="admin/uploaded_image/terrain_renders/<?php echo $row['render4']; 
   ?>">
  </div>
  </div>

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

最佳答案

确保你的内容没有静态宽度,我注意到你在 Bootstrap 中使用 Owl Carousel,所以确保你没有在那里复制任何类/有 Bootstrap carousel样式和 js 已关闭,因此没有冲突。

请注意,我只使用 !important 来克服覆盖我 100% 宽度调用的 img 样式。您不必在代码中使用 !important 标记。

.project01-carousel {
 /*width:640px;*/
 width: 100%;
max-width: none;
 height:auto;
 border: 1px solid red;
 }
 
 img {
 width: 100% !important;
 }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="col-sm-4">
  <section class="project01-carousel halfheight">
    <section class="project-carousel-wrap halfheight">
      <!-- Carousel -->
      <div class="project-carousel owl-carousel owl-nav-sticky-wide">
        <div class="project-carousel-item project-01-carousel-item-01 halfheight
          text-center">
          <img src="http://placehold.it/500x500">
        </div>
        <div class="project-carousel-item project-01-carousel-item-02 halfheight
          text-center">
          <img src="http://placehold.it/500x500">
        </div>
        <div class="project-carousel-item project-01-carousel-item-03 halfheight
          text-center">
          <img src="http://placehold.it/500x500">
        </div>
        <div class="project-carousel-item project-01-carousel-item-04 halfheight
          text-center">
          <img src="http://placehold.it/500x500">
        </div>
      </div>
    </section>
  </section>
</div>

关于html - 如何将 Bootstrap 轮播保存在容器中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44015979/

相关文章:

javascript - 在 html 中存储数据比隐藏字段更好的方法

javascript - 使用 href 值查找 anchor 标记并使用新的 href 值更改 href 值

html - 重复的 CSS 显示不一样

javascript - Twitter Bootstrap 选项卡选择不更改内容

css - 添加推特图标并正确对齐它们

html - @media 用于下拉菜单 - 显示菜单

html - 如何水平居中此警报?

html - 带有 overflow-y :scroll and fixed height 的 Chrome 文本模糊

javascript - 类 .has-error 的搜索页面

html - 将图像左对齐、文本居中、图像右对齐在同一行