+ 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?
5 odpowiedzi
+ 5
by setting the css position attribute to fixed
button{
position:fixed;
}
+ 3
Code Crasher best demo so far, i already figured it out though. Thanks for the code
+ 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.
+ 2
Add fixed position with css dor the buttom!