Return to the top button for rolling and dynamic display and hiding. Return to the top button

Source: Internet
Author: User

Return to the top button for rolling and dynamic display and hiding. Return to the top button

Many websites have the function of returning to the top to judge the dynamic display and hiding of rolling parameters. This function is suitable for beginners.

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

Return to the Code on the top of the page. Hide the code when the page is not rolled. The code is displayed after the page is rolled.

Sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/> sadfjasdkf <br/> asdfjlk <br/>
<Script language = "jav ...... remaining full text>

How to fix the button position on the top returned by html css

In many cases, you need to fix the div, such as the online consulting module. This requires that the div be fixed at the position of the display page, rather than scrolling with the scroll bar.

Idea: Make a fixed div into a floating frame to coincide with other div blocks. Then, when the scroll bar event is triggered, the div coordinates are dynamically changed.
Code:
In jsp:
<Body>
<Div style = "position: absolute; z-index: 90" id = "div1"> I don't move </div>
<Div> I am <div>
</Body>
// Some set the position to fixed. I tried to set the position to be better than the position. Set the z-index to the depth in the direction. I set it to 90 here. You need to overwrite several Divs, set the number to be greater than that.
Js:
I will write it here using jquery.
$ (Document). ready (function (){
$ (Window). scroll (function () {// triggers a function when scrolling
$ ("# Div1" ).css ("top", $ (document). scrollTop (); // assign the height of the scroll bar to the floating box.

// Add the sentence here
})
I do not have the scroll bar below, because there is no test, so it is not easy to write, if you want to try, try to add a sentence
$ ("# Div1" ).css ("right", $ (document). scrollRight (); // assign the height of the scroll bar to the floating box.
Import the jquery library.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.