分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

46.纯 CSS 创作一个在容器中反弹的小球

发布时间:2023-09-06 02:34责任编辑:董明明关键词:CSS

原文地址:https://segmentfault.com/a/1190000015221260

练习地址:https://scrimba.com/c/c3GEWmTb

感想: 原来animation 中可以有多个动画,用 ,  分开即可!

HTML code:

<div class="loader"></div>

CSS code:

html, body { ???margin: 0; ???padding: 0;}body{ ???height: 100vh; ???display: flex; ???justify-content: center; ???align-items: center; ???background-color: black;}/* 定义.loader容器尺寸*/.loader{ ???position: relative; ???font-size: 20px; ???width: 10em; ???height: 3em; ???/* silver : 银色 */ ???border: 0.3em solid silver; ???border-radius: 3em; ???/* 给容器左右两侧涂上不同颜色 */ ???border-left-color: hotpink; ???border-right-color: blue; ???/* 让容器.loader不停旋转 */ ???animation: spin 3s linear infinite;}@keyframes spin{ ???to{ ???????transform: rotate(360deg); ???}}/* 画个小球 */.loader::before{ ???content: ‘‘; ???position: absolute; ???top: 0; ???left: 0; ???width: 3em; ???height: 3em; ???border-radius: 50%; ???background-color: blue; ???/* shift : 转移 */ ???animation: ????????/* 这里居然可以放两个动画在一起,666 */ ???????shift 3s linear infinite, ???????change-color 3s linear infinite;}@keyframes shift{ ???50%{ ???????left: 7em; ???}}@keyframes change-color{ ???0%, 55%{ ???????background-color: blue; ???} ???5%, 50%{ ???????background-color: hotpink; ???}}

46.纯 CSS 创作一个在容器中反弹的小球

原文地址:https://www.cnblogs.com/FlyingLiao/p/10462207.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved