What is the right way to build simple floating divs using Javascript (or CSS programmatically)
that is on top and always visible when scrolling down?
Now I’ve seen examples like this. When you scroll down you see the div jumping and a delay. I want it to constantly be on top when the content of the page is not my ,
the script will be injected via chrome extention
can it be done?
something like this ; but less complex and not depend on the page content
With the
classoridof the element you want to keep on top you should apply some CSS rules,for example, if your element class is
.topnavigationyou could do the following in jQuery
If you can’t use jQuery you could do the following with normal javascript:
Updated: 06 Jan 2017
I’ve updated this to use the document.querySelector and Element.classList methods. All modern browsers and IE 10 > support these methods.