Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the effect of carousel by html5

Shulou Source: shulou.com Published: 2022-06-01 13:13:57 09月15日 Update

This article mainly explains "how to achieve the effect of html5". Friends who are interested may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to achieve the effect of html5".

Css:

* {margin: 0 height padding: 0} {} .container {width: 100%; overflow: hidden; / * height: 400px; * / background: red; position: relative;} .box {width: 125%; height: auto; display: flex; align-items: center; position: relative; left: 0 } .box li {width: 20%; float: left; list-style: none;-webkit-transition: width 0.5s, height 0.5s, margin 0.5s; position: relative;} .box video {width: 100%; height: 100%;} .box li div {position: absolute; top: 0; bottom: 0 Left: 0; right: 0;} .box li div img {width: 100%; height: 100%;} / * .box li:nth-child (2) {height: 360px; margin: 0.1%;} * / .goLeft, .goright {position: absolute; width: 28px; height: 52px; top: 50% Transform: translate; cursor: pointer; border: none; outline: none; line-height: 52px;} .goLeft {left: 20%;} .goright {right: 20%;} .box li > p {margin: 0; color: # fff; position: absolute; top: 50% Left: 50%; transform: translate (- 50% background 50%); text-align: center;} .box li > p > span {display: inline-block; width: 100px; height: 100px; background: url (play.png);} .ddd {width: 100%; height: 360 px; display: flex;align-items: center;position: relative } .dd-2 {width: 20%; background: yellow;} .aa {width: 100%;}

Html:

one

two

three

4 right aaavvvv

Js:

$(function () {$('.box > li:nth (1)'). Css ({width:'36% margin:'02%'}) $('.box > li:nth (1)'). Append ('video theme')}) $(window) .resize (function () {/ / when the browser size changes, $('.box'). Css ('height') ) function moveLeft () {var height = $('.box > li:nth (1)'). Height () $('.box'). Css ('height', height) $(' .box > li'). Css ({width:'20% css, margin:'00%'}) $('.box > li:nth (2)'). Css ({width:'36%') Margin:'02%'}) $('.box'). Animate ({left:'- 25%'}, 400, function () {/ / move the first child element to the last And set 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 ('video theme')}) } function moveRight () {$('.box > li'). Css ({width:' 20% margin:'00%'}) $('.box > li:nth (0)') .css ({width:'36% li:nth, margin:'02%'}) 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 ('video theme')}) } at this point, I believe you have a deeper understanding of "how to achieve the effect of html5". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Effects themes videos content learning practical deeper size elements interests size practicality practical easy to operate methods more friends browsers websites channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Microsoft MySQL macOS