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
|
8月前
|
前端开发
|
前端开发 JavaScript
使用CSS实现 图片帧动画 与 曲线运动
使用CSS实现 图片帧动画 与 曲线运动
532 0
使用CSS实现 图片帧动画 与 曲线运动
|
Web App开发 JavaScript
《HTML5+JavaScript动画基础》——1.2 帧与运动
自然,这是有代价的。随着系统变得越来越大,规则变得越来越复杂,电脑必须能够迅速地计算出下一份图像描述,并将其显示出来。如果你想保持一定的帧率,那么给予电脑的处理时间(毫秒级)就极其有限。如果电脑无法及时完成计算,帧率就会下降
1760 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 外)的速记值。
851 0
|
4天前
|
编解码 前端开发
编写代码中常见问题汇总(html和css)
编写代码中常见问题汇总(html和css)
16 0
|
3天前
|
前端开发
HTML CSS
HTML CSS
11 0
|
5天前
|
存储 JavaScript 前端开发
笔.COOL,一个功能完备、使用便捷的在线HTML/CSS/JS以及Vue编辑器和作品分享平台
笔.COOL是一个新兴的在线 HTML/CSS/JS 及 Vue 编辑器,提供实时预览和云端存储功能。用户可以随时随地编写和保存代码,同时分享作品给他人预览和学习。它也是一个实用的 BUG 复现工具,支持嵌入编辑器到博客,促进代码交流。社区活跃,适合开发者展示作品、获取灵感和学习。
|
5天前
|
存储 移动开发 前端开发
使用HTML5和CSS3构建现代网页:技术详解与实践
【5月更文挑战第28天】本文详细介绍了使用HTML5和CSS3构建现代网页的技术与实践。HTML5新增语义化标签、多媒体支持、本地存储和表单验证等功能,提升了网页开发效率和用户体验。CSS3则带来了更多选择器、盒模型改进、背景与边框样式以及动画过渡效果,使网页设计更具视觉冲击力。通过实例展示了如何结合两者创建结构清晰、交互丰富、响应式的现代网页。