博客
关于我
「HTML+CSS」--自定义加载动画【025】
阅读量:437 次
发布时间:2019-03-06

本文共 1444 字,大约阅读时间需要 4 分钟。

前言

Hello!小伙伴!

非常感谢您阅读我的文章。如果文中有错误,欢迎随时指出~
我是海轰,昵称:程序猿一只,标签:C++选手,学生。
从C语言起步,后来转入计算机专业,多次获奖,已保研。目前正在奋战C++和Linux领域,进展缓慢但在努力中~

学习经验:扎实基础 + 多做笔记 + 多敲代码 + 多思考 + 学好英语!

日常分享:微信公众号【海轰Pro】记录生活、学习点滴,分享源代码和学习资料,欢迎关注~


效果展示


Demo代码

HTML

    
Document

CSS

html, body {    margin: 0;    height: 100%;}body {    display: flex;    justify-content: center;    align-items: center;    background: #263238;}section {    width: 650px;    height: 300px;    padding: 10px;    position: relative;    display: flex;    align-items: center;    justify-content: center;    border: 2px solid red;}span {    width: 36px;    height: 36px;    border-radius: 50%;    display: inline-block;    position: relative;    border: 20px solid;    border-color: rgba(255,255,255, .25) rgba(255,255,255, 0.5) rgba(255,255,255, .75) rgba(255,255,255,1);    animation: rotation 2s linear infinite;}@keyframes rotation {    0% { transform: rotate(0deg) }    100% { transform: rotate(360deg) }}

原理详解

步骤1

使用span标签,设置CSS样式

  • 宽度、高度均为36px
  • 边框:20px solid

效果图:圆形边框呈现


步骤2

设置span边框颜色,分别设置四个边框颜色为:

  • rgba(255, 255,255, .25)
  • rgba(255,255,255, 0.5)
  • rgba(255,255,255, .75)
  • rgba(255,255,255,1)

效果图:边框颜色渐变


步骤3

span添加圆角

设置border-radius: 50%

效果图:边框圆角化


步骤4

span添加旋转动画

  • 顺时针旋转(0-360度)2秒无限循环

效果图:边框持续旋转


知识点

rgba() 函数

  • 定义:使用红、绿、蓝、透明度(A)生成颜色
  • 透明度范围:0~1,0无色透明,1完全不透明

结语

文章仅作为学习笔记,记录从0到1的一个过程。希望对您有所帮助,如有错误欢迎指正~

我是海轰(≧◡≦)如果您觉得写得可以,欢迎点赞、收藏、转发~
写作不易,「点赞」+「收藏」+「转发」
谢谢支持~

转载地址:http://zcxuz.baihongyu.com/

你可能感兴趣的文章
TCP基本入门-简单认识一下什么是TCP
查看>>
tableviewcell 中使用autolayout自适应高度
查看>>
Symbolic Aggregate approXimation(SAX,符号聚合近似)介绍-ChatGPT4o作答
查看>>
Orcale表被锁
查看>>
svn访问报错500
查看>>
Orderer节点启动报错解决方案:Not bootstrapping because of 3 existing channels
查看>>
org.apache.ibatis.exceptions.PersistenceException:
查看>>
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
查看>>
org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
查看>>
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
SQL-CLR 类型映射 (LINQ to SQL)
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
查看>>
org.tinygroup.serviceprocessor-服务处理器
查看>>
org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
查看>>