CSS效果

补间动画

1 位置-平移(left/right/margin/transform)
2 方位-旋转(transform)
3 大小-缩放(transform)
4 透明度(opacity)
5 其他-线性变换(transform)

transition

.container {
  width:100px;
  height: 100px;
  background:red;
  transition:all 1s;
}
.container:hover {
    width:800px;
    background:green;
}

关键字帧

1 相当于多个补间动画
2 与元素无关

.container {
   width:100px;
   height: 100px;
   background: red;
   animation:run 1s;
   animation-direction:reverse;
   animation-iteration-count:infinite ;//循环的次数,可以是无限循环infinite,也可以是具体的数字
   animation-play-state:paused://播放状态
   animation-fill-mode:forwards;//动画填充模式
   
   
   
}

@keyframes run {
   0% {
     width:100px
  }
  100% {
     width:800px;
  }
}

注意:如果只有这两个的话就可以写0%可以写from
100% 可以写 to

如果有其他的,就要写百分百

<div class="container" </div  

逐帧动画

1 适用于无法补间计算的动画
2 资源较大
3 使用steps()
.container {
  width:100px;
  height:100px;
  border:1px  solid  red;
  background:url(./animal.png) no-repeat;
  animation:run 1s infinite
  animation-timing-function:steps(2);
}
@keyframes  run {
  0% {
      background-position:0 0 ;
  }
  12.5% {
    background-position:-100px 0;
}
...

}

CSS动画的实现方式有几种?(面试题)

1 transition
2 keyframes(animation)

过度动画和关键帧动画的区别?

1 过渡动画需要有状态变化
2 关键帧动画不需要状态变化
3 关键帧动画能控制更精细

如何实现逐帧动画

1 使用关键帧动画
2 去掉补间(steps)

CSS 动画的性能

1 行能不坏
2 部分情况下由于JS
3 但JS可以做到更好
4 部分高危属性 box-shadow等

CSS动画与JS动画的区别

1css动画
1浏览器可以对动画进行优化
2代码冗长,想用CSS实现稍微复杂一点的动画,最后CSS代码会变的非常笨重

2JS代码
1 CSS3有兼容性问题,而JS大多数没有兼容性问题
2 代码的复杂度高于CSS动画

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个带有一些 CSS 效果的搜索引擎界面的 HTML 和 CSS 代码示例: HTML 代码: ```html <!DOCTYPE html> <html> <head> <title>搜索引擎</title> <link rel="stylesheet" type="text/css" href="style.css"> <!-- 引入 CSS 样式表 --> </head> <body> <div class="container"> <h1 class="title">搜索引擎</h1> <form action="https://www.google.com/search" method="get"> <label for="search-input">请输入搜索内容:</label> <input type="text" id="search-input" name="q"> <button type="submit">搜索</button> </form> </div> </body> </html> ``` CSS 代码: ```css .container { max-width: 500px; margin: 0 auto; padding: 20px; background-color: #f5f5f5; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); } .title { font-size: 32px; font-weight: bold; text-align: center; margin-bottom: 20px; } form { display: flex; flex-direction: column; align-items: center; } label { font-size: 18px; margin-bottom: 10px; } input[type="text"] { width: 100%; padding: 10px; font-size: 16px; border: none; border-radius: 5px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); } button[type="submit"] { width: 100%; padding: 10px; font-size: 18px; font-weight: bold; color: #fff; background-color: #007bff; border: none; border-radius: 5px; cursor: pointer; transition: all 0.3s ease; } button[type="submit"]:hover { background-color: #0062cc; } ``` 解释: 1. 在 HTML 文件的 `<head>` 中引入了一个名为 `style.css` 的 CSS 样式表。 2. 使用了一些 CSS 属性和值来对页面进行排版和美化,包括盒模型、Flex 布局、字体样式、背景颜色、边框、阴影、按钮样式等。 你可以将 HTML 和 CSS 代码保存为两个分别命名为 `index.html` 和 `style.css` 的文件,在同一目录下,并使用浏览器打开 `index.html` 文件,即可看到带有 CSS 效果的搜索引擎界面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值