HTML & CSS » 使用SVG图像作为loading加载 以保证图像高清不模糊

使用SVG图像作为loading加载 以保证图像高清不模糊

发表于: HTML & CSS, 优秀设计资源. 评论 (2)
Sponsor

今天和大家分享一个以SVG图像为主的loading加载动画,现在移动端网页使用比较多,若还用GIF做loading图片的话,可能会影响图像的质量,所以使用SVG是一个不错的方式。

这次展示的代码由 Aurer 编写,前端人员只需要直接复制想要的SVG代码就能直接使用,而且可以改变颜色。当然,对于好学的同学,也可以研究下这个代码的编写原理。

svg-animation-loading

使用教程

接下来设计达人网小编为大家讲解这个使用方法,其实是相当简单的。

STEP 1: 复制你想要的SVG加载动画代码到<body>里面,小编随意复制一个代码如下:

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="30px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<rect x="0" y="0" width="4" height="10" fill="#333" transform="translate(0 15.1665)">
<animateTransform attributeType="xml" attributeName="transform" type="translate" values="0 0; 0 20; 0 0" begin="0" dur="0.6s" repeatCount="indefinite"></animateTransform>
</rect>
<rect x="10" y="0" width="4" height="10" fill="#333" transform="translate(0 11.5002)">
<animateTransform attributeType="xml" attributeName="transform" type="translate" values="0 0; 0 20; 0 0" begin="0.2s" dur="0.6s" repeatCount="indefinite"></animateTransform>
</rect>
<rect x="20" y="0" width="4" height="10" fill="#333" transform="translate(0 1.83315)">
<animateTransform attributeType="xml" attributeName="transform" type="translate" values="0 0; 0 20; 0 0" begin="0.4s" dur="0.6s" repeatCount="indefinite"></animateTransform>
</rect>
</svg>

此时代码已经可以带动画了,但没颜色,请继续看STEP2添加颜色。

STEP 2 : 为SVG图像添加颜色

给你的样式表添加如下样式,里面的颜色代码换上你喜欢的即!

<style>
svg path,svg rect{fill: #FF6700;}
</style>

完成!最终DEMO:

svg-animation-loading-demo

是不是很简单?若在做HTML5网页时急用loading动画图像,那么使用这次我们分享的动画代码,可以快速完成一个SVG加载图像啦!

代码名称:SVG Loading images
实例地址:http://codepen.io/aurer/pen/jEGbA
推荐:查看最受欢迎的 301 个设计网站 → http://hao.shejidaren.com
交流:为设计新人提供的设计交流群,请加入UI设计交流群,分享经验、接单、求职、聊设计。
赞助商链接
赞助商链接
设计达人微信交流社区:shejidaren888
喜欢这篇文章吗?欢迎分享到你的微博、QQ群,并关注我们的微博,谢谢支持。
版权:除非注明,本站文章均为原创文章,转载请联系我们授权,否则禁止转载。

+ 添加评论2 Responses to “使用SVG图像作为loading加载 以保证图像高清不模糊”

  1. flying fish - 回复

    其他的几个load代码从哪里获取呀

  2. IvanID - 回复

    非常棒的博客,很多原创内容。


Leave a Reply to flying fish