How can I make a clickable image in Bulma change the pointer on mouseOver like <button does>?
Asked Answered
M

2

7

Loving the Bulma flow. Just wanted to make my images more obvious that they can do things when clicked.

I can bind a style with vue.js such as

<figure class="image is-128x128">
<img v-bind:src="currentTrack.coverURL"   
@mouseover="hover = true" 
@mouseleave="hover = false"
@click="playAudio()" 
:style="hover ? {opacity:0.5} : {opacity:1}" alt=""/>
</figure>

but the mouse pointer doesn't change to something that might help it seem more button like... wondering if there is an easy Bulma attribute I can add

thanks in advance!

Minardi answered 17/3, 2019 at 22:54 Comment(0)
A
10

For Bulma v0.9.1 and newer

As noted by @Relisora, the class is-clickable now ships natively with Bulma, so no extra CSS is required.


Older versions

Bulma doesn't have a built-in class for that currently, unfortunately.

You can, however, easily create a class for that! To follow Bulma conventions, let's call it is-clickable, and define it using CSS:

.is-clickable {
  cursor: pointer;
}

Now just include the class in the <figure>-element.

You can read more about the cursor-rule on MDN.

Applecart answered 24/3, 2019 at 21:18 Comment(1)
Is it also possible to make it hoverable with some text appearing?Ghislainegholston
L
2

Bulma >= 0.9.1

Use the Bulma class is-clickable.

reference - commit

Bulma < 0.9.1

You will have to add the CSS yourself, here is the code bulma used :

.is-clickable {
  cursor: pointer !important;
}
Leathaleather answered 17/12, 2020 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.