当前位置:网站首页>了解预加载和懒加载、学会缓动动画
了解预加载和懒加载、学会缓动动画
2022-07-26 03:08:00 【M78_国产007】
预加载:在加载页面时会有很多链接、图片等,提前加载资源--同源加载的优化。
懒加载: 资源先不加载 等条件成立时再加载,如我们的网页滑倒某个位置就开始加载。
现在先了解一下就行。
缓动动画
匀速改变元素的样式是匀速动画;非匀速的改变元素的样式就是缓动动画。
要实现缓动动画非常简单,记住一个公式就行:
设定值=当前值+(目标值-当前值)*百分比
配合计时器使用,每次加的越来越少,实现缓动。
小例子:
底部缓动滑入
<style>
.box{
margin: 100px auto;
width: 300px;
position: relative;
height: 450px;
overflow: hidden;
}
img{
width: 300px;
}
.info{
position: absolute;
top: 450px;
height:150px;
width: 100%;
background-color: rgba(255,255,255,0.8);
display: flex;
flex-direction: column;
justify-content: space-around
}
.info div{
height: 40px;
color: gray;
text-align: center;
}
.info div span{
color: orange;
margin-left:20px ;
}
</style>
<div class="box">
<img src="../img/明星7.jpg" alt="">
<div class="info">
<div>古力娜扎 <span>年薪:***<span></div>
<div>演员 舞者 少男杀手</div>
<div>入职***有限公司</div>
</div>
</div>
<script>
var info=document.querySelector(".info")
var box=document.querySelector(".box")
var timer1=null
var timer2=null
box.onmouseenter=function(){
clearInterval(timer2)
timer1 = setInterval(function(){
var nowcsstop=parseInt(window.getComputedStyle(info).top)
// console.log(nowcsstop);
info.style.top=nowcsstop +(300-nowcsstop)*0.5+"px"
},100)
}
box.onmouseleave=function(){
clearInterval(timer1)
timer2 = setInterval(function(){
info.style.top=parseInt(info.style.top)+(450-parseInt(info.style.top))*0.5+"px"
},100)
}
</script>边栏推荐
- Summary of Huawei virtualization fusioncompute knowledge points
- From the annual reports of major apps, we can see that user portraits - labels know you better than you do
- STM32 - DMA notes
- Hello World driver (II) - primary version
- Opencv报错:(parameter or structure field))Unrecognized or unsupported array type in functon ‘cvGetMat‘
- 手把手教你依赖管理
- Cloud native guide what is cloud native infrastructure
- 经典面试问题——OOP语言的三大特征
- [SQL] CASE表达式
- How to correctly calculate the CPU utilization of kubernetes container
猜你喜欢

ENVI_ Idl: create HDF5 file and write data (take writing GeoTIFF file to HDF file as an example) + detailed parsing

JVM内存模型解析

【C进阶】深入探索数据的存储(深度剖析+典例解读)
![[translation] safety. Value of sboms](/img/8b/1ad825e7c9b6a87ca1fea812556f3a.jpg)
[translation] safety. Value of sboms

Study notes of pytorch deep learning practice: convolutional neural network (Advanced)

【无标题】

AMD64 (x86_64) architecture ABI document:

Parallelloopbody in opencv

Information system project managers must recite the core examination site (50). The contract content is not clearly stipulated

FPGA_ Initial use process of vivado software_ Ultra detailed
随机推荐
Personally test five efficient and practical ways to get rid of orders, and quickly collect them to help you quickly find high-quality objects!
循环与分支(一)
Win11大小写提示图标怎么关闭?Win11大小写提示图标的关闭方法
Wechat official account mutual aid, open white groups, and small white newspaper groups to keep warm
信息系统项目管理师必背核心考点(五十)合同内容约定不明确规定
Shardingsphere data slicing
How to close the case prompt icon of win11? Closing method of win11 case prompt Icon
Cloud native guide what is cloud native infrastructure
Win11更改磁盘驱动器号的方法
Case: using kept+haproxy to build a Web Cluster
规范自己debug的流程
Golang 中‘...‘的用法
如何正确计算 Kubernetes 容器 CPU 使用率
Win11隐藏输入法状态栏方法
Keyboardtraffic, a tool developed by myself to solve CTF USB keyboard traffic
Chen Yili, China Academy of communications technology: cost reduction and efficiency increase are the greatest value of Enterprise Cloud native applications
Application of shift distance and hypothesis
canvas——心电图的设计,以及如何清理画布
AMD64 (x86_64) architecture ABI document:
重装Win7系统如何进行?