Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the function of imitating CSDN Blog to return to the top of the page

Shulou Source: shulou.com Published: 2022-06-03 08:35:11 11月15日 Update

This article will explain in detail how to achieve the function of imitating CSDN Blog to return to the top of the page. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Only two changes have been made:

The speed of return-- > changed to go back slowly. (it turned out to be a flash of return)

To return to the time when the top icon appears-> changed to display as long as it is not at the top. (originally displayed only after scrolling down the 500px)

Note: JS must be written after Html

HTML

The code is as follows:

TOP

Javascript code

The code is as follows:

$(function () {)

Var dumbtopping $('# dmurtopo')

_ document.onscroll=function () {

Var scrTop= (document.body.scrollTop | | document.documentElement.scrollTop)

If (scrTop > 500) {

If (scrTop > 0) {

D_top.show ()

} else {

D_top.hide ()

}

}

$('# dmurtopmura') .click (function () {

$("html,body") .animate ({scrollTop: 0} 500)

/ / scrollTo (0re0)

This.blur ()

Return false

});

});

CSS style

The code is as follows:

# d-top {

Position: fixed

Float: right

Z-index: 10

Right: 10px

Bottom: 40px

}

# d-top img {

Width: 42px

Opacity: 0.3

}

Img {

Border: medium none

}

On "how to achieve imitation of CSDN Blog back to the top of the page" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Top code article function page more good practical content icon place article timing style knowledge speed reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Shulou Information Apple Shulou Technology