Bootstrap 3轮播淡入新幻灯片而不是滑动到新幻灯片

2024-05-27

我正在使用 Bootstrap 3,未修改。

Here's

<!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
  </ol>
  <div class="carousel-inner">
    <div class="item active carousel-1">
      <div class="container">
        <div class="carousel-caption">
          <h1>Example headline.</h1>
          <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
          <p><a class="btn btn-large btn-primary" href="#">Sign up today</a></p>
        </div>
      </div>
    </div>
    <div class="item carousel-2">
      <div class="container">
        <div class="carousel-caption">
          <h1>Another example headline.</h1>
          <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
          <p><a class="btn btn-large btn-primary" href="#">Learn more</a></p>
        </div>
      </div>
    </div>

  </div>
  <a class="left carousel-control" href="#myCarousel" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div><!-- /.carousel -->

Bootstrap 3 中的默认 CSS:

.carousel {
  position: relative;
}

.carousel-inner {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.carousel-inner > .item {
  position: relative;
  display: none;
  -webkit-transition: 0.6s ease-in-out left;
          transition: 0.6s ease-in-out left;
}

.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
  display: block;
  height: auto;
  max-width: 100%;
  line-height: 1;
}

.carousel-inner > .active,
.carousel-inner > .next,
.carousel-inner > .prev {
  display: block;
}

.carousel-inner > .active {
  left: 0;
}

.carousel-inner > .next,
.carousel-inner > .prev {
  position: absolute;
  top: 0;
  width: 100%;
}

.carousel-inner > .next {
  left: 100%;
}

.carousel-inner > .prev {
  left: -100%;
}

.carousel-inner > .next.left,
.carousel-inner > .prev.right {
  left: 0;
}

.carousel-inner > .active.left {
  left: -100%;
}

.carousel-inner > .active.right {
  left: 100%;
}

.carousel-control {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 15%;
  font-size: 20px;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  opacity: 0.5;
  filter: alpha(opacity=50);
}

.carousel-control.left {
  background-image: -webkit-gradient(linear, 0 top, 100% top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0.0001)));
  background-image: -webkit-linear-gradient(left, color-stop(rgba(0, 0, 0, 0.5) 0), color-stop(rgba(0, 0, 0, 0.0001) 100%));
  background-image: -moz-linear-gradient(left, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0.0001) 100%);
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0.0001) 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);
}

.carousel-control.right {
  right: 0;
  left: auto;
  background-image: -webkit-gradient(linear, 0 top, 100% top, from(rgba(0, 0, 0, 0.0001)), to(rgba(0, 0, 0, 0.5)));
  background-image: -webkit-linear-gradient(left, color-stop(rgba(0, 0, 0, 0.0001) 0), color-stop(rgba(0, 0, 0, 0.5) 100%));
  background-image: -moz-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0, rgba(0, 0, 0, 0.5) 100%);
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0, rgba(0, 0, 0, 0.5) 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);
}

.carousel-control:hover,
.carousel-control:focus {
  color: #ffffff;
  text-decoration: none;
  opacity: 0.9;
  filter: alpha(opacity=90);
}

.carousel-control .icon-prev,
.carousel-control .icon-next,
.carousel-control .glyphicon-chevron-left,
.carousel-control .glyphicon-chevron-right {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  display: inline-block;
}

.carousel-control .icon-prev,
.carousel-control .icon-next {
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  font-family: serif;
}

.carousel-control .icon-prev:before {
  content: '\2039';
}

.carousel-control .icon-next:before {
  content: '\203a';
}

.carousel-indicators {
  position: absolute;
  bottom: 10px;
  left: 50%;
  z-index: 15;
  width: 60%;
  padding-left: 0;
  margin-left: -30%;
  text-align: center;
  list-style: none;
}

.carousel-indicators li {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 1px;
  text-indent: -999px;
  cursor: pointer;
  border: 1px solid #ffffff;
  border-radius: 10px;
}

.carousel-indicators .active {
  width: 12px;
  height: 12px;
  margin: 0;
  background-color: #ffffff;
}

.carousel-caption {
  position: absolute;
  right: 15%;
  bottom: 20px;
  left: 15%;
  z-index: 10;
  padding-top: 20px;
  padding-bottom: 20px;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.carousel-caption .btn {
  text-shadow: none;
}

@media screen and (min-width: 768px) {
  .carousel-control .icon-prev,
  .carousel-control .icon-next {
    width: 30px;
    height: 30px;
    margin-top: -15px;
    margin-left: -15px;
    font-size: 30px;
  }
  .carousel-caption {
    right: 20%;
    left: 20%;
    padding-bottom: 30px;
  }
  .carousel-indicators {
    bottom: 20px;
  }
}

我添加的一些CSS:

    .carousel {
  height: 500px;
}
.carousel-inner {
  height: 100%;
}

.carousel-1 {
  height: 100%;
  background: url(../images/carousel1.jpg)  no-repeat center center fixed;
  -webkit-background-size: cover;
  background-size: cover;
}

.carousel-2 {
  height: 100%;
  background: url(../images/carousel2.jpg)  no-repeat center center fixed;
  -webkit-background-size: cover;
  background-size: cover;
}

但我不知道如何使这个轮播具有褪色效果。 我尝试在活动项目时将不透明度从 1 更改为 0,但它会生成 2 个动画,它会向左滑动并更改不透明度。

你能帮助我吗?


由于更改,从 3.2.x 到 3.3.x 的更新破坏了此处和其他线程上解释的一些解决方案:“添加了转换以提高现代浏览器中的轮播性能。"

如果您正在使用引导程序 3.3.x这里有一个解决方案:
http://codepen.io/transportedman/pen/NPWRGq http://codepen.io/transportedman/pen/NPWRGq

基本上,您需要将“carousel-fade”类添加到您的轮播中,以便您拥有:
<div class="carousel slide carousel-fade">

然后包含以下 CSS:

/*
  Bootstrap Carousel Fade Transition (for Bootstrap 3.3.x)
  CSS from:       http://codepen.io/transportedman/pen/NPWRGq
  and:            http://stackoverflow.com/questions/18548731/bootstrap-3-carousel-fading-to-new-slide-instead-of-sliding-to-new-slide
  Inspired from:  http://codepen.io/Rowno/pen/Afykb 
*/
.carousel-fade .carousel-inner .item {
  opacity: 0;
  transition-property: opacity;
}

.carousel-fade .carousel-inner .active {
  opacity: 1;
}

.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
  left: 0;
  opacity: 0;
  z-index: 1;
}

.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
  opacity: 1;
}

.carousel-fade .carousel-control {
  z-index: 2;
}

/*
  WHAT IS NEW IN 3.3: "Added transforms to improve carousel performance in modern browsers."
  Need to override the 3.3 new styles for modern browsers & apply opacity
*/
@media all and (transform-3d), (-webkit-transform-3d) {
    .carousel-fade .carousel-inner > .item.next,
    .carousel-fade .carousel-inner > .item.active.right {
      opacity: 0;
      -webkit-transform: translate3d(0, 0, 0);
              transform: translate3d(0, 0, 0);
    }
    .carousel-fade .carousel-inner > .item.prev,
    .carousel-fade .carousel-inner > .item.active.left {
      opacity: 0;
      -webkit-transform: translate3d(0, 0, 0);
              transform: translate3d(0, 0, 0);
    }
    .carousel-fade .carousel-inner > .item.next.left,
    .carousel-fade .carousel-inner > .item.prev.right,
    .carousel-fade .carousel-inner > .item.active {
      opacity: 1;
      -webkit-transform: translate3d(0, 0, 0);
              transform: translate3d(0, 0, 0);
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Bootstrap 3轮播淡入新幻灯片而不是滑动到新幻灯片 的相关文章

  • JQuery 使用 Bootstrap 4 验证表单输入并突出显示标签[重复]

    这个问题在这里已经有答案了 我已读过 我已读过带有 jQ uery 验证插件的 Bootstrap https stackoverflow com questions 18754020 bootstrap with jquery valid
  • bootstrap-datetimepicker 仅显示日期

    我正在用这个repo https github com smalot bootstrap datetimepicker由 smalot 提供 我只想选择并显示日期 对于其他一些地方 我显示数据和时间 因此选择此存储库 我可以设法仅使用它来选
  • 使用 ember.js 模板的 Bootstrap Popovers

    我正在尝试使用引导程序弹出窗口 http twitter github io bootstrap javascript html popovers使用 EmberJS 这样弹出窗口的内容将是 ember handlebars 模板 带有绑定
  • 带预览和进度栏的 Twitter Bootstrap 图像上传

    我如何使用 Twitter Bootstrap 上传带有预览和进度条的单个图像 目前 在保存图像之前 我看不到上传图像的任何预览或进度条 Jasny 的 Bootstrap 分支让您能够接近这一点 看文档 http jasny github
  • 如何显示隐藏前一个模式的新模式窗口?

    Using 鼓室网 http tympanus net codrops 2013 06 25 nifty modal window effects 模态 带有很棒的动画 很容易删除背景 div div class md overlay di
  • 如何使用 jQuery AJAX 和 JSON 通过 Bootbox 确认表单提交

    我正在使用一个网络应用程序工作Spring MVC 我试图在提交表单之前显示一个确认对话框Bootbox 但我收到 500 内部服务器错误 这是我的表格
  • 将自定义数据与引导日期选择器中的日期绑定

    我有特定日期注册的总用户数 就像下图一样 我怎样才能显示它们和日期 我在用多日期选择器 http multidatespickr sourceforge net 有什么办法可以做到这一点吗 UPDATE 预先选定的日期 with altFi
  • Morris.js 图表在引导选项卡内无法工作

    我遇到一种情况 我尝试在两个不同的内部使用 MorrisJS 图表引导选项卡 http getbootstrap com javascript tabs 图表在第一个 默认 选项卡中加载良好 但当我单击第二个选项卡时 图表根本无法正确加载
  • 如何更改 bootstrap 版本 4 按钮颜色

    我可以通过更改 bootstrap v4 中的主题颜色来更改主按钮颜色 但它也会影响所有其他组件 如何设置主按钮颜色而不影响主题颜色 我不想设置品牌为主并实现它 还有其他选择吗 Bootstrap 4 1 2019 年更新 现在 Boots
  • 在 Symfony 2 项目中安装 Bootstrap 主题

    我正在考虑安装这个主题 http bootswatch com superhero 在我的SF2项目中 我注意到页面顶部有4个文件可供下载 即 bootstrap min css 引导程序 css 无变量 bootswatch less 我
  • 在单引导模式上显示图像

    我正在执行一项任务 我需要很少的图像 并且我想在引导模式中显示图像 我已经完成了下面的代码 以便在单击链接时在模态上显示图像 其中链接具有以下图像 每个图像都有链接 模态与所有图像一起打开 但问题是我不想为每个图像创建模态
  • 使用 twitter-bootstrap 时使文本区域缩放到网页

    我正在尝试根据页面大小调整文本区域的比例 即我试图使文本区域填充第二个容器和页脚之间的空间 HTML
  • 我应该如何使用 Bootstrap 设计 Django 验证错误的样式?

    当 Django 中的表单出现验证错误时 错误会在包含类的列表中给出errorlist 可以通过设置使用 Bootstrap 为元素指定错误样式class alert alert error 结合这些并使用 Bootstrap 的错误样式来
  • 模态内的引导程序表单未正确对齐

    我尝试使用引导程序 水平形式 制作模式形式 并且该字段显示在标签下 知道如何修复它 以便输入文本框位于标签的右侧而不是标签的下方吗 div class modal hide fade div class modal header div d
  • 在调整窗口大小之前,ChartJS 不会在引导选项卡内绘制图表

    我正在使用 Bootstrap 的选项卡 每个选项卡内都带有 ChartJS 图表 但出现的一个问题是图表画布wont被绘制 直到我调整浏览器窗口的大小 最新的 Chrome 和 Firefox 都发生了这种情况 我一直在尝试不同的解决方案
  • 如何获取 Bootstrap Datepicker 更改时的年份和月份

    我是这个日期选择器的新手 我不知道如何获取更改事件的月份和年份字符串changeMonth and changeYear 这是该插件的链接 https github com eternicode bootstrap datepicker h
  • 使用 Twitter Bootstrap 解除警报不起作用?

    我正在使用谷歌浏览器 Using 推特引导程序 http twitter github com bootstrap 我想添加一个简单的警报 不幸的是alert http twitter github com bootstrap compon
  • Bootstrap 折叠导航菜单

    我正在尝试使用 Bootstrap 折叠插件 但收效甚微 我想要一个带有隐藏子菜单的手风琴式导航菜单 我的 HTML 和 JS ul class nav nav list li class nav header span Home span
  • 引导导航栏菜单与文本重叠

    我使用最新版本的引导程序 当我调整屏幕浏览器的大小时 使用小切换按钮下拉导航栏时 导航栏会重叠页面上的文本 而不是向下推页面内容 我已经多次研究过这个问题 我尝试将 padding bottom 放在导航栏上 将 padding top 放
  • Draggable JS Bootstrap 模式 - 性能问题

    对于工作中的项目 我们在 JavaScript 中使用 Bootstrap Modal 窗口 我们想让一些窗口可移动 但我们遇到了 JQuery 的性能问题 myModal draggable handle modal header Exa

随机推荐

  • 如何用OpenCV解决图像处理相机IO延迟

    我有一个 OpenCV 程序 其工作原理如下 VideoCapture cap 0 Mat frame while true cap gt gt frame myprocess frame 问题是如果myprocess耗时较长 超过相机的I
  • RecyclerView 仅在某些项目之间添加分隔线

    我想在我的中添加分隔线RecyclerView Layout 我已经搜索了一段时间 但我只能找到利用的解决方案RecyclerView addItemDecoration 这会在所有项目之间添加分隔线 我可以创建一个只有一行的布局并将其添加
  • Hibernate JTA:读取每个环境的数据库连接参数

    我正在使用 hibernate 编写一个 javaEE 应用程序 该应用程序将在多个环境 dev qa prod 等 上运行 并且将具有与每个环境关联的单独的数据库 我想为每个环境分别设置 hibernate 属性 如 jdbc url 用
  • Presto 数组包含一个喜欢某种模式的元素

    例如 我的表中的一列是一个数组 我想检查该列是否包含包含子字符串 denied 的元素 因此 在中午 12 00 拒绝 被管理员拒绝 等元素都将计数 我相信我将不得不使用 like 来识别模式 这个sql该怎么写呢 使用急板数组函数 htt
  • 使用 Git 处理 subversion:忽略对跟踪文件的修改

    我目前正在使用 subversion 存储库 但我正在使用 git 在我的计算机上本地工作 它使工作变得更加容易 但也使 subversion 存储库中发生的一些不良行为变得非常明显 这给我带来了问题 拉取代码后 有一个有点复杂的本地构建过
  • DOM更改后刷新浏览器悬停效果

    我有一个 css 已更改的元素 hover 我还有一些 javascript 可以改变元素的高度 但是如果 javascript 在 hoverstate 处于活动状态 即使高度变化将元素从鼠标下方移出 状态仍保持不变 另外 由于 java
  • 任意类的 const 和非 const 成员函数的模板包装器

    我想要一个模板化类 包装器 它可以采用所有可能的类 T 并使用这些类 函数 的成员函数做一些事情 这里评估 我发现了类似的请求 你可以看看here https stackoverflow com questions 11090109 non
  • 绘制给定 bin 端点和值的直方图

    假设我有一个 bin 边缘数组和一个 bin 值数组 基本上输出plt hist 例如 bins np array 1 2 3 4 5 vals np array 2 5 5 2 如何将其绘制为直方图 编辑 为了清楚起见 我的意思是 val
  • iPhone 6模拟器,隐藏键盘问题

    iPhone 6 是否有一些新的方式 屏幕外 硬按钮 来重新打开隐藏的软键盘 我没有可以测试的物理设备 但我在 iPhone 6 模拟器中看到了一些在 iPad 或 iPhone 5 中看不到的新东西 iPhone 6 在横向视图中现在有一
  • 访问 webapp 外部的文件(Tomcat V6 和 Spring)

    我提供上传图像的选项 并且图像正在上传到 opt uploads contactImages 在 Windows 中为 C opt uploads contactImages 我想在我的 JSP 中显示图像 为此 我尝试通过在主机标签下添加
  • 打印出匿名子程序的代码

    我目前正在一个非常复杂的 Perl 架构中工作 我想创建一些调试工具 由于许多行为涉及匿名子例程 因此我想分析其中一些行为 而我所要做的就是对子例程的引用 简而言之 有没有办法打印子例程引用的代码 因为 Perl 被解释 它可能仍然可用 核
  • 右值和左值上的成员函数重载造成混淆

    我有以下设置 struct foo void bar std cout lt lt lvalue n void bar std cout lt lt rvalue n foo bar int main int arg char argv f
  • Spring MVC 中 init binder 的用途是什么

    这是互联网上 init binder 的代码 InitBinder public void initBinder WebDataBinder binder SimpleDateFormat dateFormat new SimpleDate
  • 使用 REST 协议和 JSON 数据格式测试 Web 服务的最佳工具是什么? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我是使用 JSON 数据格式测试 REST Web 服务的新手 我尝试了SOUPUI 但不幸的是不支持
  • 在 Windows 上以 QML 播放 RTSP 视频

    我正在尝试将 QML 中的 RTSP 流播放到视频标签中 如下所示 Repeater model 8 Video Layout fillWidth true Layout fillHeight true fillMode VideoOutp
  • 为什么 iloc() 的一种使用会给出SettingWithCopyWarning,而另一种则不会?

    在类的方法中 我使用以下语句 self datacontainer iloc 1 c value 这样做我得到一个 设置复制警告 试图在 DataFrame 中的切片副本上设置一个值 现在我尝试重现此错误并编写以下简单代码 import p
  • 在 Perl 中检测全局破坏

    我想检测我的物体是否被DESTROY作为全局破坏的一部分 并打印出警告 因为这显然是一个错误并导致数据丢失 显而易见的方法似乎是 sub DESTROY my self shift if i am in global destruction
  • ContentValues放置方法

    在数据库端 checkInTime and checkOutTime属于类型TIMESTAMP 在我的java代码中 checkInTime and checkOutTime属于类型java sql Timestamp 为了将记录插入数据库
  • TensorFlow:使用不同的输入张量重新运行网络?

    假设我在 TensorFlow 中有一个典型的 CNN 模型 def inference images images 4D tensor of batch size IMAGE SIZE IMAGE SIZE 3 size conv 1 c
  • Bootstrap 3轮播淡入新幻灯片而不是滑动到新幻灯片

    我正在使用 Bootstrap 3 未修改 Here s div class carousel slide ol class carousel indicators li class active li li li ol div class