Home  >  Article  >  Web Front-end  >  Imitation CSDN Blog return to the top of the page function implementation principle and code_html5 tutorial skills

Imitation CSDN Blog return to the top of the page function implementation principle and code_html5 tutorial skills

WBOY
WBOYOriginal
2016-05-16 15:49:141631browse

Only 2 places have been modified:
, the speed of return --> changed to go back slowly. (It turned out to be a flash back)
, the timing of the return to top icon appearing --> changed to be displayed as long as it is not at the top. (It turned out to be displayed after scrolling down 500px)

Note: JS must be written after Html;
HTML

Copy the code
The code is as follows:

Javascript code

Copy code
The code is as follows:



CSS style

Copy code
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;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn