html5+css如何实现中间大两头小的轮播效果

HTML教程 2025-08-14

国际惯例,先上效果

好了,话不多说,上去就是一顿撸。

css:

html:

aaa
vvvv

js:

$(function(){    $('.box>li:nth(1)').css({ width: '36%', margin: '0 2%' })    $('.box>li:nth(1)').append('视频主题')    })$(window).resize(function () {          //当浏览器大小变化时    $('.box').css('height', 'auto')})function moveLeft(){        var height = $('.box>li:nth(1)').height()        $('.box').css('height', height)        $('.box>li').css({ width: '20%', margin: '0 0%' })        $('.box>li:nth(2)').css({ width: '36%', margin: '0 2%' })        $('.box').animate({            left: '-25%'        }, 400, function () {            // 把第一个子元素移到最后,并且设置left=0            $(.box).append($('.box>li:nth(0)')[0]);            $(.dd-2).append($('.aa')[0]);            $(.aa).append('ccc');            $('.box').css('left', 0);            $(.btn).attr(disabled, false);            $('.box>li:nth(1)').append('视频主题')        });    }    function moveRight(){        $('.box>li').css({ width: '20%', margin: '0 0%' })        $('.box>li:nth(0)').css({ width: '36%', margin: '0 2%' })        var height = $('.box>li:nth(1)').height()        $('.box').css('height', height)        $(.box).prepend($('.box>li:nth(3)')[0]);                $('.box').css('left', '-20%');        $('.box').animate({            left: 0        }, 400, function () {            $(.btn).attr(disabled, false);            $('.box>li:nth(1)').append('视频主题')        });    }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。

注:相关教程知识阅读请移步到HTML教程频道。