最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

css3實現(xiàn)動態(tài)滾動播放列表功能

  發(fā)布時間:2024-09-11 17:02:51   作者:不一樣又怎樣   我要評論
在Web開發(fā)中,動態(tài)滾動播放列表能夠提升用戶體驗,使內(nèi)容展示更加生動有趣,本文介紹了如何僅使用CSS3實現(xiàn)一個基礎(chǔ)的循環(huán)播放列表,其中關(guān)鍵技術(shù)包括@keyframes規(guī)則和animation相關(guān)屬性,感興趣的朋友一起看看吧

需要自動滾動循環(huán)播放的列表,使用純CSS實現(xiàn)基礎(chǔ)循環(huán)功能

    .messages
        animation-name carousel
        animation-timing-function linear
        animation-iteration-count infinite
        .message-item
            cursor pointer
            margin-top 10px
        &.stopPlay
            animation-play-state paused
            /**
              CSS3 animation-play-state 屬性 值為paused時暫停動畫,為running時繼續(xù)動畫
             */
    @keyframes carousel {
        0% {
            transform: translateY(0%)
        }
        100% {
            transform: translateY(-50%)
        }
    }

完整代碼

<template>
    <div>
        <div class="top-line">
            <div class="box-title">
                <span class="title">XXXX專題圖</span>
            </div>
        </div>
        <div class="scroll-box">
            <ul class="messages" @mouseover="stopAnim" @mouseout="runAnim" v-if="list.length"
                :style="{ animationDuration: animationDuration }" :class="{ stopPlay: animationPlayState }">
                <li class="message-item" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
                    <div class="message-top">
                        <span class="message-title">{{ item.name }}</span>
                        <span class="message-time">{{ item.startDate }}</span>
                    </div>
                    <p class="message-content">{{ item.content }}</p>
                </li>
            </ul>
            <div class="none" v-else>
                暫無內(nèi)容
            </div>
        </div>
    </div>
</template>
<script>
import test11List from '@/assets/test11List'
export default {
    data() {
        return {
            animationDuration: '',
            animationPlayState: false,
            list: test11List.list,
            category: ''
        };
    },
    mounted() {
        this.getData()
    },
    methods: {
        getData() {
            let data = this.list
            if (data.length <= 2) {
                this.animationPlayState = true
                this.animationDuration = 2 + 's'//動畫持續(xù)時間
            } else {
                // 跑馬燈動畫
                this.animationDuration = data.length * 2 + 's'
                this.list = this.list.concat(this.list)
            }
        },
        stopAnim() {//鼠標移入暫停動畫
            this.animationPlayState = true
        },
        runAnim() {//鼠標移除繼續(xù)動畫
            if (this.list.length > 2) {
                this.animationPlayState = false
            }
        }
    },
};
</script>
<style lang="stylus" scoped>
    *{
        margin: 0
        padding: 0
    }
    ul{
        list-style: none
    }
    .scroll-box{
        width 100%
        height 800px
        overflow hidden
        border 2px solid red
    }
    .box-title
        line-height 34px
        font-size 16px
        background: blue
        color: #fff
        opacity 1
    .messages
        animation-name carousel
        animation-timing-function linear
        animation-iteration-count infinite
        .message-item
            cursor pointer
            margin-top 10px
        &.stopPlay
            animation-play-state paused
            /**
              CSS3 animation-play-state 屬性 值為paused時暫停動畫,為running時繼續(xù)動畫
             */
    .none
        text-align center
        line-height 537px
        color #fff
    @keyframes carousel {
        0% {
            transform: translateY(0%)
        }
        100% {
            transform: translateY(-50%)
        }
    }
</style>

到此這篇關(guān)于css3實現(xiàn)動態(tài)滾動播放列表的文章就介紹到這了,更多相關(guān)css3滾動播放列表內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

海伦市| 盐亭县| 江北区| 马公市| 云阳县| 天门市| 和静县| 罗田县| 瑞丽市| 昌图县| 东丰县| 舞阳县| 莲花县| 祁阳县| 修武县| 邵东县| 五莲县| 浦北县| 龙口市| 烟台市| 鄢陵县| 荆州市| 余干县| 南靖县| 浙江省| 金塔县| 安塞县| 德令哈市| 博野县| 五寨县| 阿瓦提县| 会泽县| 井冈山市| 木兰县| 哈密市| 韶山市| 瓦房店市| 灵台县| 汉川市| 共和县| 舒城县|