Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non clickable object that looks like button in Bootstrap 3

Is there an easy (non-hackish?) way to make a Bootstrap button lookalike that's not clickable (and I don't mean a disabled button). Basically a <div class="btn btn-default">Something</div> that doesn't behave like a link.

Thanks in advance

like image 433
pawel.ad Avatar asked Oct 23 '15 18:10

pawel.ad


People also ask

How do I make a button not clickable in Bootstrap?

Active/Disabled Buttons The class . active makes a button appear pressed, and the disabled attribute makes a button unclickable. Note that <a> elements do not support the disabled attribute and must therefore use the . disabled class to make it visually appear disabled.

How do I make a button not clickable in HTML?

To make a button non-clickable, you can enter: pointer-events: none; into the button module's "Button Settings > Advanced > Custom CSS > Main Element" box, like so: Note that this will also disable the hover effect on the button.


1 Answers

As @benrwb mentioned in the comments, the most elegant solution would be to set the elements style property "pointer-events" to "none".

E.g.

<button type="button" class="btn btn-primary">My Button</button>

becomes

<button type="button" class="btn btn-primary" style="pointer-events: none;">My Button</button>

This doesn't only work on Bootstrap buttons, but also every other HTML element that has some kind of hover actions.

like image 132
McSebi Avatar answered Sep 19 '22 09:09

McSebi