Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report