首页 > 其他分享 >css3 animation实现动态无缝轮播1

css3 animation实现动态无缝轮播1

时间:2022-12-19 17:57:06浏览次数:48  
标签:css3 box translateX 轮播 ul -- transform width animation



<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      li {
        list-style: none;
      }

      img {
        width: 200px;
      }
      
      .box {
        width: 600px;
        height: 112px;
        border: 5px solid #000;
        margin: 100px auto;

        overflow: hidden;
      }
      /* 给大包括加总宽度 */
      .box ul {
        /* (7+3)*200=2000px */
        width: 2000px; 
        /* infinite重复  linear匀速运动 */
        animation: move 5s infinite linear;
      }

      .box li {
        /* 本来是竖直的,弄成水平的 */
        float: left;
      }

      /* 定义动画:位移, ul 左侧使用  x -1400  */
      @keyframes move {
        to {
          transform: translateX(-1400px);
        }
      }

      /* 用户鼠标移入box,动画暂停 */
      .box:hover ul {
        animation-play-state: paused;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <ul>
        <li><img src="./images/1.jpg" alt="" /></li>
        <li><img src="./images/2.jpg" alt="" /></li>
        <li><img src="./images/3.jpg" alt="" /></li>
        <li><img src="./images/4.jpg" alt="" /></li>
        <li><img src="./images/5.jpg" alt="" /></li>
        <li><img src="./images/6.jpg" alt="" /></li>
        <li><img src="./images/7.jpg" alt="" /></li>

        <!-- 第567移动的时候,显示区域不能留白 -->
        <li><img src="./images/1.jpg" alt="" /></li>
        <li><img src="./images/2.jpg" alt="" /></li>
        <li><img src="./images/3.jpg" alt="" /></li>
      </ul>
    </div>
  </body>
</html>

 

<div class="box" :style="{
'--card-ul-width-start':-30+'px',
'--card-ul-width-middle1':-cap.length*30+'px', 
'--card-ul-width-middle2':-cap.length*60+'px',
'--card-ul-width-end':-cap.length*90+'px'
}">
    <ul :style="{'-webkit-animation':cap.length*8+ 's move infinite linear;'}">
        <li></li>
    </ul>
</div>
data(){
    cap:new Array(6).fill('https://res.minigame.vip/gc-assets/fruit-master/fruit-master_icon.png')
}@keyframes move {
    0%{
    transform:translateX(var(--card-ul-width-start))
    }
    30%{
    transform:translateX(var(--card-ul-width-middle1))
    }
    70%{
    transform:translateX(var(--card-ul-width-middle2))
    }
    100%{
transform:translateX(var(--card-ul-width-end)) }

 

标签:css3,box,translateX,轮播,ul,--,transform,width,animation
From: https://www.cnblogs.com/lyk562564104/p/16992740.html

相关文章

  • css3 animation实现动态无缝轮播
    <divclass="box":style="{'--card-ul-width-start':-30+'px','--card-ul-width-middle1':-cap.length*30+'px','--card-ul-width-middle2':-cap.length*60+'px','-......
  • Playable API - AnimationClip与AnimatorController放在一起使用
    与这边类似PlayableAPI-简单动画混合-yanghui01-博客园(cnblogs.com),只是跑动画换成了状态机usingUnityEditor.Animations;usingUnityEngine;usingUnityEng......
  • Playable API - 多个Animation Clip间切换播放
    #用到的脚本usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.Animations;usingUnityEngine.Playables;publicclassPlayAnimClipOneByO......
  • Playable API - 简单播放Animation Clip
    用到的资源:GitHub-unity3d-jp/unitychan-crs:Unity-Chan"CandyRockStar"LiveDemo这边直接在他提供的Scene上修改PlayableAPI来播放AnimationClip的脚本:usin......
  • requestAnimationFrame
    window.requestAnimationFrame()用浏览器刷新频率(通常是每秒60/75次)执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数......
  • CSS3 上传图片虚线边框
    .upload-area{margin-top:1.25rem;border:none;background-image:url("data:image/svg+xml,%3csvgwidth='100%25'height='100%25'xmlns='http://www.w3.o......
  • HTML5&CSS3.0基础部分目录-xyphf
    [置顶]​​CSS3.0入门笔记​​[置顶]​​animate.css动画库使用方法介绍​​[置顶]​​聊一聊HTML5的表单,话说这些表单你都用过吗?​​[置顶]​​聊一聊HTML5存储......
  • 有bug的轮播套简单轮播图,懒得修复
    <!DOCTYPEhtml><html><head>  <metacharset="utf-8"/>  <title>sada</title></head><style>  #tyu{        position:relative;......
  • animation顺序 及案例
    animation 属性是 animation-name,animation-duration, animation-timing-function,animation-delay,animation-iteration-count,animation-direction,animation-fill-mode ......
  • Android:通过 Banner 和 Glide 在 Fragment 中实现轮播图
    添加依赖包通过Banner和Glide实现轮播图。引入第三方库:dependencies{implementation'io.github.youth5201314:banner:2.2.2'implementation'com.github.bum......