您现在的位置是:亿华云 > 知识
开发指导—利用CSS动画实现HarmonyOS动效(二)
亿华云2025-10-04 03:48:13【知识】4人已围观
简介注:本文内容分享转载自HarmonyOSDeveloper官网文档点击查看 《开发指导—利用CSS动画实现HarmonyOS动效一)》
注:本文内容分享转载自HarmonyOS Developer官网文档
点击查看 《开发指导—利用CSS动画实现HarmonyOS动效(一)》
3. background-position样式动画
通过改变background-position属性(第一个值为X轴的指导位置,第二个值为Y轴的利用位置)移动背景图片位置,若背景图位置超出组件则超出部分的动动效背景图不显示。
<!-- xxx.hml --> <div class="container"> <div class="content"></div> <div class="content1"></div> </div> /* xxx.css */ .container { height: 100%; background-color:#F1F3F5; display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; } .content{ width: 400px; height: 400px; /* 不建议图片长宽比为1:1 */ background-image: url(common/images/bg-tv.jpg); background-size: 100%; background-repeat: no-repeat; animation: change 3s infinite; border: 1px solid black; } .content1{ margin-top:50px; width: 400px; height: 400px; background-image: url(common/images/bg-tv.jpg); background-size: 50%; background-repeat: no-repeat; animation: change1 5s infinite; border: 1px solid black; } /* 背景图片移动出组件 */ @keyframes change{ 0%{ background-position:0px top; } 25%{ background-position:400px top; } 50%{ background-position:0px top; } 75%{ background-position:0px bottom; } 100%{ background-position:0px top; } } /* 背景图片在组件内移动 */ @keyframes change1{ 0%{ background-position:left top; } 25%{ background-position:50% 50%; } 50%{ background-position:right bottom; } 100%{ background-position:left top;; } }说明
background-position仅支持背景图片的画实移动,不支持背景颜色(background-color)。指导
4. svg动画
为svg组件添加动画效果。利用
属性样式动画
在Svg的服务器托管动动效子组件 animate中,通过attributeName设置需要进行动效的画实属性,from设置开始值,指导to设置结束值。利用
<!-- xxx.hml --> <div class="container"> <svg> <text x="300" y="300" fill="blue"> Hello <animate attributeName="font-size" from="30" to="60" dur="3s" repeatCount="indefinite"> </animate> <animate attributeName="fill" from="red" to="blue" dur="3s" repeatCount="indefinite"> </animate> <animate attributeName="opacity" from="1" to="0.3" dur="3s" repeatCount="indefinite"> </animate> </text> <text x="300" y="600" fill="blue"> World <animate attributeName="font-size" from="30" to="60" values="30;80" dur="3s" repeatCount="indefinite"> </animate> <animate attributeName="fill" from="red" to="blue" dur="3s" repeatCount="indefinite"> </animate> <animate attributeName="opacity" from="0.3" to="1" dur="3s" repeatCount="indefinite"> </animate> </text> </svg> </div>说明
在设置动画变化值时,动动效如果已经设置了values属性,画实则from和to都失效。指导
路径动画
在Svg的利用子组件 animateMotion中,云南idc服务商通过path设置动画变化的动动效路径。
<!-- xxx.hml --> <div class="container"> <svg fill="white" width="800" height="900"> <path d="M300,200 h-150 a150 150 0 1 0 150 -150 z" fill="white" stroke="blue" stroke-width="5" > </path> <path fill="red" d="M-5,-5 L10,0 L-5,5 L0,0 Z" > <animateMotion dur="2000" repeatCount="indefinite" rotate="auto-reverse"path="M300,200 h-150 a150 150 0 1 0 150 -150 z"> </animateMotion> </path> </svg> </div>animateTransform动画
在Svg的子组件 animateTransform中,通过attributeName绑定transform属性,type设置动画类型,from设置开始值,to设置结束值。
<!-- xxx.hml --> <div class="container" style=""> <svg> <line x1="90" y1="300" x2="90" y2="730" stroke-width="10" stroke="black" stroke-linecap="round"> <animateTransform attributeName="transform" attributeType="XML" type="translate" dur="3s" values="0;30;10;30;20;30;25;30" keyTimes="0;0.3;0.5;0.7;0.8;0.9;1.0;1.1" fill="freeze"> </animateTransform> </line> <circle cx="500" cy="500" r="50" stroke-width="15" fill="red" stroke="#e70d0d"> <animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="3s" values="0;30;10;30;20;30;25;30" keyTimes="0;0.3;0.5;0.7;0.8;0.9;1.0;1.1" fill="freeze"> </animateTransform> <animateTransform attributeName="transform" attributeType="XML" type="scale" dur="6s" values="1;1;1.3" keyTimes="0;0.5;1" fill="freeze"></animateTransform> <animateTransform attributeName="transform" attributeType="XML" type="translate" dur="9s" values="0;0;300 7" keyTimes="0;0.6;0.9" fill="freeze"></animateTransform> </circle> <line x1="650" y1="300" x2="650" y2="600" stroke-width="20" stroke="blue" stroke-linecap="round"> <animateTransform attributeName="transform" attributeType="XML" type="translate" dur="9s" values="0;0;0 800" keyTimes="0;0.6;1" fill="freeze"></animateTransform> </line> </svg> </div> /* xxx.css */ .container { flex-direction: column; align-items: center; width: 100%; height: 100%; background-color: #F1F3F5; }很赞哦!(7589)
相关文章
- 其次,一般域名注册有一个获取密码的按钮,域名注册商点击后会向您发送密码。在得到域名注册商发送的密码后,将其传输到域名服务提供商网站,然后输入密码,此时域名呈现申请状态。提交申请后,原注册人通常会向您发送一封电子邮件,询问您是否同意转让。此时,您只需点击同意转移按钮,域名注册商就可以成功转移。
- 为了避免将来给我们的个人站长带来的麻烦,在选择域名后缀时,我们的站长最好省略不稳定的后缀域名,比如n,因为我们不知道策略什么时候会改变,更不用说我们将来是否还能控制这个域名了。因此,如果站长不是企业,或者有选择的话,如果不能选择域名的cn类,最好不要选择它。
- 第六:这个圈子里的域名确实是赚钱的一些大玩家,至于小米农,有多少赚钱?几乎没有,也就是说,轿子里只有一个人,而且大多数人都抬着轿子。
- 5. 四种状态过后,域名管理机构释放域名给公众注册。
- (4) 使用何种形式的域名后缀对网页搜索影响不大,但域名后缀也需要考虑方便用户记忆
- Status、Creation Date、Expiration Date
- 个人域名转为公司需要什么条件?个人域名转为公司该怎么做?
- 其次,一般域名注册有一个获取密码的按钮,域名注册商点击后会向您发送密码。在得到域名注册商发送的密码后,将其传输到域名服务提供商网站,然后输入密码,此时域名呈现申请状态。提交申请后,原注册人通常会向您发送一封电子邮件,询问您是否同意转让。此时,您只需点击同意转移按钮,域名注册商就可以成功转移。
- ④注册门槛低
- 5. 四种状态过后,域名管理机构释放域名给公众注册。
热门文章
站长推荐
3、不明先知,根据相关征兆预测可能发生的事件,以便提前做好准备,赶紧注册相关域名。;不差钱域名;buchaqian抢先注册,就是这种敏感类型。预言是最敏感的状态。其次,你应该有眼力。所谓眼力,就是善于从社会上时不时出现的各种热点事件中获取与事件相关的域名资源。眼力的前提是对域名领域的熟悉和丰富的知识。
如果你的潜在终端必须是这个米(域名),那么潜在终端并不多,也没有硬通货,那么你的域名应该在终端有兴趣购买时出售。否则,你可能得自己留着吃。
四、配置网站,填充内容
域后缀首选.com,.net,然后是.cn。后缀选择不当,导致流量损失。域名是企业与互联网网址之间的链接,关键是企业在网络上存在的标志。因此,选择好域名是开展网上工作的首要重要条件。
互联网中的地址是数字的IP地址,域名解析的作用主要就是为了便于记忆。
比较短的域名方便用户记忆和传播,它带来的好处往往会超过其他类型的域名,如果你非要域名短而且还要包含关键词,那么往往会事与愿违,现在这种域名基本上是可遇而不可求的。
并非一个好米任何人都会给你一个好的价格。那你该如何用以有的好米卖出最理想的价格呢?
用户邮箱的静态密码可能已被钓鱼和同一密码泄露。在没有收到安全警报的情况下,用户在适当的时间内不能更改密码。在此期间,攻击者可以随意输入帐户。启用辅助身份验证后,如果攻击者无法获取移动电话动态密码,他将无法进行身份验证。这样,除非用户的电子邮件密码和手机同时被盗,否则攻击者很难破解用户的邮箱。