I’m building a website in which there are teo ways to scroll
1)scroll snapping
2)traditional
now:
html,body{
margin: 0;
scroll-snap-type:y mandatory ;
flex-direction: column;}
But I want to make button which can turn off scroll sanpping.
I know I can edit css of the body but how to edit the css of the HTML?
2
Answers
Add button with (JavaScript) onclick value:
Create a button in your HTML to toggle scroll snapping:
Add an event listener to the button to toggle the scroll snapping behavior:
Define your CSS rules to enable or disable scroll snapping based on the class applied to the element:
Apply the CSS class to the element when the button is clicked: