当前位置:网站首页>Scroll case: return to top with animation
Scroll case: return to top with animation
2022-07-25 23:41:00 【qiaokelizhuzhu】
Case study : Back to top with animation
css style
.box {
width: 800px;
height: 400px;
background-color: blanchedalmond;
margin: 500px auto;
}
.box2 {
position: fixed;
right: 10px;
top: 50%;
display: none;
width: 50px;
height: 50px;
background-color: red;
}
html
<div class=box></div>
<div class="box2"> Return to the top </div>
jQuery Code
ps: animate Only elements can be animated
$(function() {
var box = $(".box").offset().top; // obtain box2 Head distance
$(window).scroll(function() {
if ($(document).scrollTop() >= box) {
// If Scroll to box2 Distance of Just box2 Will be displayed
$(".box2").css("display", "block")
} else {
$(".box2").css("display", "none")
}
})
$(".box2").click(function() {
$("body,html").stop().animate({
//animate Only elements can be animated
scrollTop: 0
})
})
})
边栏推荐
- [QNX Hypervisor 2.2用户手册]9.7 generate
- Leetcode 0136. numbers that appear only once: XOR
- 【MUDUO】打包EventLoop和Thread
- 获取马蜂窝酒店数据
- [nodejs] nodejs create a simple server
- numeric学习之iota,accumulate
- Loading process such as reflection
- 【代码案例】博客页面设计(附完整源码)
- initializer_ List tool library learning
- Learning exploration - waves
猜你喜欢

Why are there many snapshot tables in the BI system?

Release of v6.5.1/2/3 series of versions of Xingyun housekeeper: the ability of database OpenAPI continues to be strengthened

Learning exploration - waves

XxE & XML external entity injection utilization and bypass

S4/HANA ME21N创建PO 输出控制消息按钮丢失解决方法(切换EDI 输出模式BRF+至NAST模式)

电商RPA,大促轻松上阵的法宝

Taobao Search case

ES6 syntax (difference between let, const, VaR, deconstruction assignment, arrow function, residual parameters, extension method of array)
![[code case] blog page design (with complete source code)](/img/9e/0e7cab956515b9cc75a7567eb477d2.png)
[code case] blog page design (with complete source code)

Multimodal deep multi modal sets
随机推荐
Serialize operator
Loading process such as reflection
Summary of built-in instructions and custom instructions
[QNX hypervisor 2.2 user manual]9.7 generate
firewall 命令简单操作
【MUDUO】打包EventLoop和Thread
XxE & XML external entity injection utilization and bypass
LeetCode 0135. 分发糖果
initializer_list工具库学习
Read the field status of account in ABAP code (hidden, optional, required)
Overview of MES system equipment management (Part 2)
ES6 syntax (difference between let, const, VaR, deconstruction assignment, arrow function, residual parameters, extension method of array)
新手开户选择哪个券商公司好呢?安全吗
arcgis根据矢量范围裁取tif影像(栅格数据)、批量合并shp文件、根据矢量范围裁取区域内的矢量,输出地理坐标系、转换16位TIF影像的像素深度至8位、shp文件创建和矢量框标绘设置
Classes and objects (3)
Optimize the browsing experience of yandere/konachan site with user scripts
[testing technology automated testing pytest] basic summary of pytest
S4/hana ME21N create Po output control message button missing solution (switch EDI output mode brf+ to Nast mode)
Programmer interview Golden Classic 4.12 summation path
Recursion of function (use recursion to find the factorial of 1-N) (use recursion to find Fibonacci sequence) (use recursion to traverse data)