北京中交建设工程咨询有限公司网站,用Html5做网站,百度智能小程序生态,深圳建筑设计网站文章目录 前言transition属性语法宽度改变效果透明度改变效果位置改变效果如有启发#xff0c;可点赞收藏哟~ 前言
通常#xff0c;当一个元素的样式属性值发生变化时#xff0c;会立即看到页面发生变化。 css属性transition能让页面元素不是立即的、而是慢慢的从一种状态变… 文章目录 前言transition属性语法宽度改变效果透明度改变效果位置改变效果如有启发可点赞收藏哟~ 前言
通常当一个元素的样式属性值发生变化时会立即看到页面发生变化。 css属性transition能让页面元素不是立即的、而是慢慢的从一种状态变成另外一种状态从而表现出一种动画过程。
transition属性语法
属性介绍transition-property元素的哪一个属性将用过渡表现。例如, opacity,color。默认值是all。transition-duration元素过渡过程持续时间。例如1s。默认值是0s。transition-timing-function元素过渡时的速率函数。例如, linear、 ease-in、steps动画分段函数或自定义的 cubic-bezier 函数)。默认值是ease中间快两头慢。transition-delay元素过渡延迟的时间。例如1s。默认值是0stransition没有定义上述的可以按照上述的属性依次填写空格格式。且可以以逗号隔开操作多种不同元素属性的配置 属性和方法太多可按实际效果调试 宽度改变效果
templatediv classcontent :class{content-fade: fade}/div
/templatescript
import { defineComponent, ref } from vue;export default defineComponent({name: App,components: {},setup() {const fade ref(true);const change () (fade.value !fade.value);setInterval(() {change()}, 4000);return {fade,};},
});
/script
style scoped
.content {width: 200px;height: 120px;background-color: aqua;transition: width 3s;/* transition: width 3s steps(3); */
}
.content-fade {width: 50px;
};
/style透明度改变效果
templatediv classcontent :class{content-fade: fade}/div
/templatescript
import { defineComponent, ref } from vue;export default defineComponent({name: App,components: {},setup() {const fade ref(true);const change () (fade.value !fade.value);change()setInterval(() {change()}, 3000);return {fade,};},
});
/script
style scoped
.content {width: 200px;height: 120px;background-color: aqua;transition: opacity 3s ;
}
.content-fade {opacity: 0;
};
/style位置改变效果
templatediv classpagedivclasscircle:class[fade ? circle-fade-in : circle-fade-out]/div/div
/templatescript
import { defineComponent, ref } from vue;export default defineComponent({name: App,components: {},setup() {const fade ref(true);const change () (fade.value !fade.value);setInterval(() {change();}, 5000);return {fade,};},
});
/script
style scoped
.page {width: 100vw;height: 100vh;position: relative;
}
.circle {position: absolute;width: 120px;height: 120px;border-radius: 50%;background-color: aqua;transition: all 5s linear;
}
.circle-fade-in {top: 0px;left: 0px;
}
.circle-fade-out {top: calc(100vh - 120px);left: calc(100vw - 120px);
}
/style如有启发可点赞收藏哟~