加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 如何使用Bootstrap轮播显示上一张和下一张图像

发布时间:2020-12-14 21:17:10 所属栏目:资源 来源:网络整理
导读:我正在寻找的效果可以在下面的图像中看到,它是一个有3张图像的旋转木马. 如何让bootstrap carousel显示不透明度为0.7的左右图像? 以下是我的轮播模板. div class="col-md-10 center-block" img id="logo" src="./img/yoox_group.png" alt="yoog group" / di
我正在寻找的效果可以在下面的图像中看到,它是一个有3张图像的旋转木马.

如何让bootstrap carousel显示不透明度为0.7的左右图像?

以下是我的轮播模板.

<div class="col-md-10 center-block">
    <img id="logo" src="./img/yoox_group.png" alt="yoog group" />

    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
            <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
            <li data-target="#carousel-example-generic" data-slide-to="1"></li>
            <li data-target="#carousel-example-generic" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner" role="listbox">
            <div class="item active">
                <img src="./img/carousel/carousel-001.jpg" alt="..." />
                <div class="carousel-caption">
                </div>
            </div>
            <div class="item">
                <img src="./img/carousel/carousel-002.jpg" alt="..." />
                <div class="carousel-caption">
                </div>
            </div>
            <div class="item">
                <img src="./img/carousel/carousel-003.jpg" alt="..." />
                <div class="carousel-caption">
                </div>
            </div>
        </div>
        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
            <img id="arrowleft" src="./img/arrow_left.png" />
            <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
            <img id="arrowright" src="./img/arrow_right.png" />
            <span class="sr-only">Next</span>
        </a>
    </div>
</div>
#arrowleft {
    background-color: #FFF;
    padding: 10px 8px;
    position: absolute;
    margin-left: -95px;
    top: 45%;
    z-index: 5;
    display: inline-block;
}
#arrowright {
    background-color: #FFF;
    padding: 10px 8px;
    position: absolute;
    margin-left: 67px;
    top: 45%;
    z-index: 5;
    display: inline-block;
}

解决方法

将 this answer扩展到另一个问题,如果您将以下css添加到您的代码中,它将提供您正在寻找的效果.

我们基本上必须将.carousel-inner扩展为大于.carousel,然后将其居中并隐藏.carousel的溢出.

为了获得不透明效果,我们扩展上一个和下一个箭头容器的大小,然后设置半透明的白色背景.

Bootstrap> = 3.3.0

在Bootstrap版本3.3.0 there was a change in the CSS which invalidated the previous method中.所以这是当前的方法.

(Demo)

.carousel {
    overflow: hidden;
}
.carousel-inner {
    width: 150%;
    left: -25%;
}
.carousel-inner > .item.next,.carousel-inner > .item.active.right {
    -webkit-transform: translate3d(33%,0);
    transform: translate3d(33%,0);
}
.carousel-inner > .item.prev,.carousel-inner > .item.active.left {
    -webkit-transform: translate3d(-33%,0);
    transform: translate3d(-33%,0);
}
.carousel-control.left,.carousel-control.right {
    background: rgba(255,255,0.3);
    width: 25%;
}

Bootstrap< 3.3.0 (Demo)

.carousel {
    overflow: hidden;
}
.carousel-inner {
    width: 150%;
    left: -25%;
}
.carousel-inner .active.left {
    left: -33%;
}
.carousel-inner .next {
    left: 33%;
}
.carousel-inner .prev {
    left: -33%;
}
.carousel-control.left,0.3);
    width: 25%;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读