韩漫免费漫画在线观看方法,《好好疼爱里面》免费看,年轻漂亮的女士护士内衣,妈妈醉酒后把我当爸爸电视剧

文章 > css教程 > CSS实现轮播图的方法

CSS实现轮播图的方法

CSS轮播图

头像

小妮浅浅

2021-08-30 09:47:408034浏览 · 0收藏 · 0评论

实现思路

1、通过animation达到动起来的效果,具体变化似乎有两种可行方式:

2、在动画中,通过CSS-transform不断平移轮播图元素位置。

3、在动画中,设置不同的left值。

实现效果与代码

其中值得注意的点在于需要手动在轮播图头部添加最后一张图的复制,否则会有明显的闪动效果。

实例

<!DOCTYPE html>
 
<body>
    <div style="flex: 1;height: 300px;z-index: 10;box-shadow: inset 0 0 300px rgba(0, 0, 0, 0.99);">
        left
    </div>
    <div class="showbox border box-shadow">
        <div class="left border">
            左
        </div>
        <div class="right border">
            右
        </div>
        <div id="imgbox" class="center imgbox">
            <img src="https://cdn.pixabay.com/photo/2018/01/03/05/33/the-sun-3057622__340.jpg" />
            <img src="https://cdn.pixabay.com/photo/2021/07/29/20/23/mountains-6508015_960_720.jpg" />
            <img src="https://cdn.pixabay.com/photo/2021/07/29/21/03/cereals-6508088__340.jpg" />
            <img src="https://cdn.pixabay.com/photo/2018/01/03/05/33/the-sun-3057622__340.jpg" />
        </div>
    </div>
    <div  style="flex: 1;height: 300px;z-index: 10;box-shadow: inset 0 0 300px rgba(0, 0, 0, 0.99);" >
        right
    </div>
</body>
<!-- <script>
    let a = 0
    let max = 300 * 3;
    window.onload = function() {
        refresh();
    }
 
    function refresh() {
        document.getElementById("imgbox").style.left = a + "px";
    }
 
    function left() {
        a = (a-300)%max;
        refresh();
    }
 
    function right () {
        a = (a+300)%max;
        refresh();
    }
 
</script> -->
<style>
    body {
        width: 100%;
        height: 100%;
        z-index: 0;
        /* background-color: rgba(0, 0, 0, 0.5); */
        box-shadow: inset 0 0 300px rgba(0, 0, 0, 0.1);
    }
 
    .center {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }
 
    .showbox {
        width: 300px;
        height: 300px;
        /* background: chocolate; */
        position: relative;
        overflow: visible;
 
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        /* z-index: -1; */
        opacity: 1;
    }
 
    .left {
        position: absolute;
        left: 0;
        top: 50%;
        cursor: pointer;
        background: blue;
        z-index: 100;
    }
 
    .right {
        position: absolute;
        right: 0;
        top: 50%;
        cursor: pointer;
        background: blue;
        z-index: 100;
    }
 
    .border {
        border: 1px solid black;
    }
 
    .centerimg {
        width: 100%;
        height: 100%;
    }
 
    .myimg {
        width: 300px;
        height: 300px;
        z-index: -1;
        opacity: 1;
        /* filter: alpha(opacity=60); */
    }
    .imgbox {
        position: absolute;
        left: -600px;
        top: 0;
        z-index: -1;
        animation: slideshow 10s both infinite;
    }
 
    @keyframes slideshow {
        0% {
            left: -900px;
        }
        33% {
            left: -600px;
        }
        66% {
            left: -300px;
        }
        100% {
            left: 0;
        }
    }
</style>
 
</html>

以上就是CSS实现轮播图的方法,希望对大家有所帮助。更多css学习指路:css教程

本文教程操作环境:windows7系统、css3版,DELL G3电脑。

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

朋友的妈妈7中字谜| 《温柔的大姐姐》动漫免费观看| 亲嘴还扔衣服| 草编包| 《金莲淫史》台湾绝版| 飞花艳想!| 《疯狂瑜伽》完整版| 高H文| 1秒流鼻血的女性胸片| 少女配狗视频大全播放| TOUPAIZIPAI| 《再来一次好吗》动漫| 在野外自慰和陌生人做了| 线人2009| 两阳夹一阴与其他强势形态的比较| 粗大的内捧猛烈进出校花H漫画小| 电影《满足2》完整版在线观看| 怎么骑桌角到失禁| 录像狗配女人| 扌暴辶鬲和扌吴辶的区别| 欧美人动物PPT免费模板大全| 老人玩小处雌女视频的意义| 丫头把腿开大让我添添| 俄罗斯少女2免费观看| 妈妈装睡配合孩子阴阳调和| 老公装醉看我和别人在一起| 《头等舱》韩国电影在线看| 金装律师第二季| 女性一晚上3次纵欲导致不孕 | 女生把球球给男生抓的视频| 同学的母亲中字ID| 小寡妇在线观看免费播放电视剧 | 成品人和精品人的区别在哪里知乎 | 护士二姐妹精神诊所| 特殊按摩治疗师| 《喂奶人妻厨房HD》| 美国《性船》无删减| 《女仆教育》动漫第一季 | 极品家丁| 欧美-区| 怎么才能怀孕?