类web开发,如何设置组件的样式展示动画

类web开发,如何设置组件的样式展示动画

HarmonyOS
2024-08-01 09:34:17
1335浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
电子土豆片

通过关键帧(Keyframes)动态设置父组件的width和height,实现组件的大小变化。同时,通过设置子组件的scale属性,使父子组件同时缩放。通过调整opacity属性实现父子组件的显示和隐藏。

<div class="container">
  <div class="fade">
    <text>fading away</text>
  </div>
  <div class="bigger">
    <text>getting bigger</text>
  </div>
</div>

.container {
  background-color:#F1F3F5;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
}
.fade {
  width: 30%;
  height: 200px;
  left: 35%;
  top: 25%;
  position: absolute;
  animation: 2s change infinite friction;
}
.bigger {
  width: 20%;
  height: 100px;
  background-color: blue;
  animation: 2s change1 infinite linear-out-slow-in;
}
text {
  width: 100%;
  height: 100%;
  text-align: center;
  color: white;
  font-size: 35px;
  animation: 2s change2 infinite linear-out-slow-in;
}
/* 颜色变化 */
@keyframes change{
  from {
    background-color: #f76160;
    opacity: 1;
  }
  to {
    background-color: #09ba07;
    opacity: 0;
  }
}
/* 父组件大小变化 */
@keyframes change1 {
  0% {
    width: 20%;
    height: 100px;
  }
  100% {
    width: 80%;
    height: 200px;
  }
}
/* 子组件文字缩放 */
@keyframes change2 {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1.5);
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
分享
微博
QQ
微信
回复
2024-08-01 18:15:35


相关问题
如何设置组件不同状态下样式
2693浏览 • 1回复 待解决
RichEditor组件如何设置初始字体样式
1656浏览 • 1回复 待解决
如何设置Web组件深色模式?
1081浏览 • 1回复 待解决
HarmonyOS 组件/容器设置背景样式
1284浏览 • 1回复 待解决
HarmonyOS web界面开发如何设置代理调试
1135浏览 • 1回复 待解决
HarmonyOS 以后SDK还有web开发模式不?
1177浏览 • 1回复 待解决
web组件如何设置请求头
942浏览 • 1回复 待解决
富文本在web组件中无法展示
2923浏览 • 1回复 待解决
HarmonyOS 动画展示
430浏览 • 1回复 待解决
设置组件不同状态下样式
2839浏览 • 1回复 待解决
LoadingProgress如何修改加载动画样式
2435浏览 • 1回复 待解决
Web组件如何获取和设置UserAgent
3901浏览 • 1回复 待解决