To make a button unclickable in CSS, you can use the pointer-events
property. The pointer-events property is used to control various mouse events on elements.
So, If you set the pointer-events
property to none
for a button, it will make it unclickable.
Let’s say we have a button with a class 'disabled'
in our HTML file:
<button class="disabled">Disabled button</button>
To make it unclickable, we will set its pointer-events
property to none
in our CSS file:
.disabled{ pointer-events: none; opacity: 0.6; }
This is how the button will look like after applying the above styles:
Thanks for reading.