html - 带有 Bootstrap 3 的 ResponsiveSlides.js

标签 html css twitter-bootstrap responsive-slides

我试图将 ResponsiveSlides slider 置于 Bootstrap 列的中心,但无法使其工作。我有很大的图片,所以我在 css 中将它们的大小调整为 80%。当它是 100% 时,它们适合整个屏幕,但现在它们向左对齐。有人可以帮忙吗?谢谢你!

<div class="col-xs-12">    
<ul class="rslides">
<li><a href="#"><img src="..." alt=""></a></li>
<li><a href="#"><img src="..." alt=""></a></li>
</ul>
</div>

CSS:

.rslides {
  position: relative;
  list-style: none;
  overflow: hidden;
  width: 100%;
  padding: 0;
  }

.rslides li {
  -webkit-backface-visibility: hidden;
  position: absolute;
  display: none;
  width: 100%;
  left: 0;
  top: 0;
  }

.rslides li:first-child {
  position: relative;
  display: block;
  float: left;
  }

.rslides img {
  display: block;
  height: auto;
  float: left;
  width: 80%;
  border: 0;
  }

最佳答案

我觉得把 UL 的宽度设置为 80%,img 设置为 100% 应该会更好

.rslides {
    width: 80%;
    margin: 0 auto;
}

如果你想在不改变容器的情况下使 IMG 居中,你必须移除 float: left;和相同的边距:0 auto;

.rslides img {
    display: block;
    height: auto;
    float: left;  <-- remove this
    width: 80%;
    border: 0;
    margin: 0 auto; <-- add
}

关于html - 带有 Bootstrap 3 的 ResponsiveSlides.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36724349/

相关文章:

javascript - 为什么我不能在这里更改 zIndex?

css - 通过 CSS 重用 SVG 渐变

facebook - 像 Facebook 这样的通知栏

asp.net-mvc - 用于枚举下拉列表的自定义 MVC 模板

javascript - 在 HTML/CSS 表格下方显示总数

html - 为什么有些元素的背景会延伸到 DIV 的宽度,而有些则不会?

javascript - 在 jQuery 中使用特定数据 ID 在 li 中添加 href 的属性

html - 用空的 div 填充 td contenteditable

html - 响应式设计和隐藏 div 元素

twitter-bootstrap - Bootstrap 响应图像列的图像大小应该是多少?