新闻动态

良好的口碑是企业发展的动力

html动画效果代码

发布时间:2023-11-13 08:37:22 点击量:958
定制模板

 

HTML动画效果可以通过CSS和JavaScript来实现,下面给出一些常见的动画效果及其代码。

 

1. 内容逐字显示动画(Typewriter Animation)

这个效果可以使文本内容一个个字逐渐出现,营造打字机打字的效果。

 

HTML:

```html

Animated Typewriter Effect

```

 

CSS:

```css

#typewriter {

overflow: hidden;

border-right: .15em solid orange;

white-space: nowrap;

margin: 0 auto;

letter-spacing: .15em;

animation:

typing 3.5s steps(40

end)

 

blink-caret .75s step-end infinite;

}

 

@keyframes typing {

from { width: 0 }

to { width: * }

}

 

@keyframes blink-caret {

from

to { border-color: transparent }

50% { border-color: orange; }

}

```

 

2. 旋转动画(Rotate Animation)

这个效果可以使一个元素沿着一定的轴线旋转。

 

HTML:

```html

```

 

CSS:

```css

#rotate-animation {

width: 100px;

height: 100px;

background-color: red;

animation: rotate 3s infinite linear;

}

 

@keyframes rotate {

0% { transform: rotate(0deg) }

* { transform: rotate(360deg) }

}

```

 

3. 渐变动画(Fade Animation)

这个效果可以使一个元素从透明到不透明或从不透明到透明的过渡。

 

HTML:

```html

```

 

CSS:

```css

#fade-animation {

width: 100px;

height: 100px;

background-color: red;

animation: fade 3s infinite;

}

 

@keyframes fade {

0% { opacity: 0 }

50% { opacity: 1 }

* { opacity: 0 }

}

```

 

4. 缩放动画(Scale Animation)

这个效果可以使一个元素在一定时间内不断放大或缩小。

 

HTML:

```html

```

 

CSS:

```css

#scale-animation {

width: 100px;

height: 100px;

background-color: red;

animation: scale 3s infinite ease-in-out alternate;

}

 

@keyframes scale {

0% { transform: scale(1); }

50% { transform: scale(1.5); }

* { transform: scale(1); }

}

```

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:dm@cn86.cn进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。本站原创内容未经允许不得转载。
标签:
上一篇: bootstrap模板网
下一篇: 西安网站建设