+ 5

In html, how can i make a button float on the page even if the page is being scrolled?

Making the button stay on one point of the page, though it can be moved to whichever part of the page, it should not slide out of the visble window. How can i do this?

18th Mar 2020, 6:27 AM
Alfred Juma
Alfred Juma - avatar
5 Answers
+ 5
by setting the css position attribute to fixed button{ position:fixed; }
18th Mar 2020, 6:36 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 3
Code Crasher best demo so far, i already figured it out though. Thanks for the code
19th Mar 2020, 6:39 AM
Alfred Juma
Alfred Juma - avatar
+ 2
In general, doing: #myButton{ position: fixed; } should work (assuming your button has an id of "button"). You can also use position: sticky; which will toggle between relative and fixed positioning depending on the user's current scroll position. The button will appear to "stick" to the top of the window if you scroll past a certain point. I'd also avoid using "button" (or, in general, tag names) as selectors; using "button" as a selector will apply that styling to ALL buttons.
19th Mar 2020, 5:31 AM
HealyUnit
HealyUnit - avatar
+ 2
Add fixed position with css dor the buttom!
19th Mar 2020, 2:50 PM
CodeFu
CodeFu - avatar