html_css模拟端午赛龙舟运动

简介: html_css模拟端午赛龙舟运动

⭐前言

大家好,我是yma16,本期给大家分享css实现赛龙舟运动。

💖 样式布局

风格:卡通

首先采用一张包括水元素的照片作为背景

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>annimation</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100vw;
        height: 100vh;
        background: url(./background.jpg);
        background-repeat: no-repeat;
        background-size: cover;
        display: grid;
        grid-template: 1fr/1fr;
      }
    </style>
  </head>
  <body>
  </body>
</html>

背景图和龙舟的布局

💖 添加龙舟

使用ul的li元素配置龙舟属性添加龙舟图片

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>annimation</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100vw;
        height: 100vh;
        background: url(./background.jpg);
        background-repeat: no-repeat;
        background-size: cover;
        display: grid;
        grid-template: 1fr/1fr;
      }
      .box {
        margin: 0 auto;
      }
      ul {
        display: block;
        position: absolute;
        top: 300px;
        left:0;
      }
      li {
        text-align: center;
        color: #000;
        line-height: 80px;
        text-transform: uppercase;
        height: 80px;
        width: 200px;
        opacity: 1;
        color: #fff;
      }
      .li-boat {
        height: 300px;
        width: 300px;
        background: url(./boat.png);
        background-repeat: no-repeat;
        background-size: cover;
      }
    </style>
  </head>
  <body>
    <div class='box'>
      <ul>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
      </ul>
    </div>
  </body>
</html>

💖 添加css_animation运动

水平移动

@keyframes move {
  from {
    transform: translateX(0vh);
  }
  to {
    transform: translateX(80vh);
  }
}
li:nth-child(1) {
  animation-timing-function: ease;
}
li:nth-child(2) {
  animation-timing-function: ease-in;
}
li:nth-child(3) {
  animation-timing-function: ease-in-out;
}
li:nth-child(4) {
  animation-timing-function: ease-out;
}
li:nth-child(5) {
  animation-timing-function: linear;
}

完整的代码如下

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>annimation</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100vw;
        height: 100vh;
        background: url(./background.jpg);
        background-repeat: no-repeat;
        background-size: cover;
        display: grid;
        grid-template: 1fr/1fr;
      }
      .box {
        margin: 0 auto;
      }
      ul {
        display: block;
        position: absolute;
        top: 300px;
        left: 0;
      }
      li {
        text-align: center;
        color: #000;
        line-height: 80px;
        text-transform: uppercase;
        height: 80px;
        width: 200px;
        animation-name: move;
        animation-duration: 12s;
        animation-iteration-count: infinite;
        transform: translateY(80vh);
        opacity: 1;
        color: #fff;
      }
      .li-boat {
        height: 300px;
        width: 300px;
        background: url(./boat.png);
        background-repeat: no-repeat;
        background-size: cover;
      }
      @keyframes move {
        from {
          transform: translateX(0vh);
        }
        to {
          transform: translateX(150vh);
        }
      }
      li:nth-child(1) {
        animation-timing-function: ease;
      }
      li:nth-child(2) {
        animation-timing-function: ease-in;
      }
      li:nth-child(3) {
        animation-timing-function: ease-in-out;
      }
      li:nth-child(4) {
        animation-timing-function: ease-out;
      }
      li:nth-child(5) {
        animation-timing-function: linear;
      }
      .title{
        width:auto;
        height: 50px;
        text-align: center;
        margin: 0 auto;
        color: rgb(89, 114, 189);
        background: #fff;
        font-size: 32px;
        font-weight: bold;
      }
    </style>
  </head>
  <body>
    <div class='title'>
      <img src="boat.png" height="30px"/>端午节赛龙舟活动<img src="boat.png" height="30px"/>
      </div>
    <div class='box'>
      <ul>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
        <li>
          <div class="li-boat"></div>
        </li>
      </ul>
    </div>
  </body>
</html>

效果如下

inscode的代码如下

⭐结束

本文分享结束!

💖感谢你的阅读💖

如有更好的意见欢迎指出!


目录
相关文章
|
18天前
|
前端开发
css_animation运动的贝塞尔曲线
css_animation运动的贝塞尔曲线
16 0
|
7月前
|
前端开发
|
前端开发 JavaScript
使用CSS实现 图片帧动画 与 曲线运动
使用CSS实现 图片帧动画 与 曲线运动
528 0
使用CSS实现 图片帧动画 与 曲线运动
|
Web App开发 JavaScript
《HTML5+JavaScript动画基础》——1.2 帧与运动
自然,这是有代价的。随着系统变得越来越大,规则变得越来越复杂,电脑必须能够迅速地计算出下一份图像描述,并将其显示出来。如果你想保持一定的帧率,那么给予电脑的处理时间(毫秒级)就极其有限。如果电脑无法及时完成计算,帧率就会下降
1756 0
|
前端开发
css 运动背景
css 运动背景原理: animation-name: bgmove;animation-duration: 100s; animation-timing-function: linear; animation-delay: 0; animation-iteration-count: infinite; animation介绍: 属性 描述 animation 指定定义所有动画属性(除了 animation-play-state 外)的速记值。
850 0
|
4天前
|
移动开发 HTML5
HTML5/CSS3粒子效果进度条代码
HTML5/CSS3进度条应用。这款进度条插件在播放进度过程中出现粒子效果,就像一些小颗粒从进度条上散落下来
15 0
HTML5/CSS3粒子效果进度条代码
|
8天前
|
移动开发 前端开发 JavaScript
:掌握移动端开发:HTML5 与 CSS3 的高效实践
:掌握移动端开发:HTML5 与 CSS3 的高效实践
22 1
|
13天前
|
缓存 移动开发 前端开发
【专栏:HTML与CSS前端技术趋势篇】HTML与CSS在PWA(Progressive Web Apps)中的应用
【4月更文挑战第30天】PWA(Progressive Web Apps)结合现代Web技术,提供接近原生应用的体验。HTML在PWA中构建页面结构和内容,响应式设计、语义化标签、Manifest文件和离线页面的创建都离不开HTML。CSS则用于定制主题样式、实现动画效果、响应式布局和管理字体图标。两者协同工作,保证PWA在不同设备和网络环境下的快速、可靠和一致性体验。随着前端技术进步,HTML与CSS在PWA中的应用将更广泛。
|
13天前
|
前端开发 JavaScript 开发者
【专栏:HTML与CSS前端技术趋势篇】前端框架(React/Vue/Angular)与HTML/CSS的结合使用
【4月更文挑战第30天】前端框架React、Vue和Angular助力UI开发,通过组件化、状态管理和虚拟DOM提升效率。这些框架与HTML/CSS结合,使用模板语法、样式管理及组件化思想。未来趋势包括框架简化、Web组件标准采用和CSS在框架中角色的演变。开发者需紧跟技术发展,掌握新工具,提升开发效能。