圆弧和扇形的加载动画该怎么写?

0.静态效果图

圆弧和扇形的加载动画该怎么写?圆弧和扇形的加载动画该怎么写?

1.画弧度的代码

width: 3em;height: 3em;border: 7px transparent solid;border-left: 7px #4DB6AC solid;border-radius: 50%;

登录后复制

  

* 这里还有另一个方式

border-left:7px #4DB6AC solid;border-radius: 50%;border-top:7px transparent solid;border-bottom:7px transparent solid;

登录后复制

  后者做成旋转动画效果不如前者,肉眼能感到差异,在chrome49.

2.画扇形的代码

border: 7px transparent solid;border-left: 7px #4DB6AC solid;border-radius: 50%;

登录后复制

  

* 画扇形不可以定义宽度和长度,其余与画圆弧相同

3.less 封装画圆弧和扇形的代码

圆弧和扇形的加载动画该怎么写?圆弧和扇形的加载动画该怎么写?

.arc(@direction,@style){@color:~`"@{style}".split(/,s+/)[1]`;@width:~`"@{style}".split(/,s+/)[0].replace("[","")`;@shape:~`"@{style}".split(/,s+/)[2].replace("]","")`;border: @width transparent @shape;@length:length(@direction);.setStyle(@length,@style,@direction);border-radius: 50%;.setStyle(@length,@style,@direction) when (@length>0){@index:@length - 1;@pos:extract(@direction,@length);border-@{pos}:@style ;.setStyle(@index,@style,@direction);}}//使用方式:@driection 可以是top、left、right、bottom中的一个或多个@style 需要严格按照 7px solid red 这样的顺序.arc(left,7px solid red);.arc(left top,7px solid red);

登录后复制View Code

4.加载动画的完整代码

圆弧和扇形的加载动画该怎么写?圆弧和扇形的加载动画该怎么写?

Document html,body {  overflow: hidden;  width: 100%;  height: 100%;}.container {  display: -webkit-box;  display: -ms-flexbox;  display: flex;  -ms-flex-wrap: wrap;  flex-wrap: wrap;  -webkit-box-pack: space-around;  -ms-flex-pack: space-around;  justify-content: space-around;  margin: 0 auto;  max-width: 650px;  min-width: 200px;}.container .canvas {  -webkit-box-align: center;  -ms-flex-align: center;  align-items: center;  display: -webkit-box;  display: -ms-flexbox;  display: flex;  -webkit-box-pack: center;  -ms-flex-pack: center;  justify-content: center;  background: #eee;  border-radius: 50%;  -webkit-box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);  height: 10em;  width: 10em;  margin: 1em 1em 2em 1em;}.container .canvas .spinner4 {  width: 3em;  height: 3em;  border: 7px transparent solid;  border-left: 7px #4DB6AC solid;  border-radius: 50%;  -webkit-animation: spinner4 1s linear infinite;  animation: spinner4 1s linear infinite;}@-webkit-keyframes spinner4 {  100% {            -webkit-transform: rotate(360deg);-ms-transform: rotate(360deg);-o-transform: rotate(360deg);transform: rotate(360deg);  }}        @keyframes spinner4 {  100% {            -webkit-transform: rotate(360deg);-ms-transform: rotate(360deg);-o-transform: rotate(360deg);transform: rotate(360deg);  }}        .container .canvas .spinner5 {  border: 1.5em transparent solid;  border-right: 1.5em #4DB6AC solid;  border-left: 1.5em #4DB6AC solid;  border-radius: 50%;  -webkit-animation: spinner5 1s linear infinite;  animation: spinner5 1s linear infinite;}@-webkit-keyframes spinner5 {  0% {            transform: rotate(0deg);  }  50% {transform: rotate(60deg);  }  100% {transform: rotate(360deg);  }}        @keyframes spinner5 {  0% {            transform: rotate(0deg);  }  50% {transform: rotate(60deg);  }  100% {transform: rotate(360deg);  }}        .container .canvas .spinner6 {  width: 1em;  height: 1em;  border-radius: 50%;  background-color: #4db6ac;  margin: 0.1em;  -webkit-animation: fall 1s linear infinite;  animation: fall 1s linear infinite;}        

登录后复制View Code

5.声明

案例代码是我从网上看到的,我自己模仿了一下但无论效果和方法上都不如前者。

欣慰的是能够知道原理,只是细节之处还需练习。

以上就是圆弧和扇形的加载动画该怎么写?的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2910704.html

(0)
上一篇 2025年3月11日 04:35:39
下一篇 2025年2月28日 04:45:21

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • 使用Vue按需加载提升用户体验

    vue官方文档异步组件: 在大型应用中,我们可能需要将应用拆分为多个小模块,按需从服务器下载。为了让事情更简单, Vue.js 允许将组件定义为一个工厂函数,动态地解析组件的定义。Vue.js 只在组件需要渲染时触发工厂函数,并且把结果缓存…

    2025年3月11日 编程技术
    200
  • ngAnimate插件是做什么的?

    ngAnimate插件是做什么的? nganimate插件如其名字一样是为元素提供动画的。 怎么定义动画? 第一步必须是引入插件 登录后复制   第二步让app引入(依赖)这个插件 登录后复制登录后复制登录后复制 var appH5=ang…

    编程技术 2025年3月11日
    200
  • H5编辑器核心思想的实例分析

    代码和特性在chrome49下测试有效。 文本渲染的本质是对文本节点的渲染,通过浏览器内置的对象Range可以获得选择的起始点、与终止点 var range = getRangeObject();var start = range.star…

    编程技术 2025年3月11日
    200
  • html5动画中关于等待加载动画的实例分享

    html5动画中关于等待加载动画的实例分享          100 登录后复制 *{margin:0;padding:0;}    .loading{          height:100%;width:100%;position:fi…

    2025年3月11日
    200
  • 弹性盒模型-容器属性的理解

      布局的传统方案,基于盒装模型,依赖display属性+position属性+float属性。他对于那些特殊的布局非常不方便,比如,垂直居中就不容易实现。  2009年,w3c提出了一种新的方案—-flex布局,可以简便、完整、响应式地实…

    2025年3月11日 编程技术
    200
  • HTML5如何绘制动画?(代码实例)

    本篇文章给大家带来的内容是关于html5如何绘制动画?(代码实例) ,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。 虽然canvas的API并未直接提供支持动画的方法,但就其本身而言,在canvas中实现动画效果也很简单:…

    2025年3月11日
    200
  • HTML5实现对话气泡点击动画

    本篇文章给大家介绍一下使用html5实现对话气泡点击动画的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。 需求 还是要先把需求拿出来。 要求: 对话气泡要有动画,动画总共4秒在没有点击的时候,气泡每隔8秒出现一次在点…

    2025年3月11日
    200
  • HTML5+CSS3动态画出一个大象

    在之前的文章《利用css制作有趣的文字摆动动画特效》中,我们介绍了利用css制作有趣文字摆动动画特效的方法。这次我们给大家介绍一下利用html5+css3如何动态画出一个大象,感兴趣的可以学习了解一下~ 今天本文的主要内容是:利用HTML5…

    2025年3月11日 编程技术
    200
  • 如何使用HTML5+CSS3动态画一个笑脸

    在之前的文章中我们介绍了利用html5+css3动态画出一个大象的方法,感兴趣的可以点击链接进行查阅→《html5+css3动态画出一个大象》。这次我们继续聊聊利用html5+css3实现动画效果,介绍一下动态画一个笑脸的方法。 今天本文的…

    2025年3月11日 编程技术
    200
  • css3动画效果总结分析

    css3的动画功能有以下三种: 1、transition(过度属性)2、animation(动画属性)3、transform(2D/3D转换属性) 下面逐一进行介绍我的理解: 1、transition: 如-webkit-transitio…

    2025年3月11日
    200

发表回复

登录后才能评论