mjmlio / mjml

MJML: the only framework that makes responsive-email easy
https://mjml.io
MIT License
16.91k stars 952 forks source link

Button hover not working #1683

Closed m-gleeson closed 5 years ago

m-gleeson commented 5 years ago

Having a hard time doing something seemingly very simple.... can't seem to get button hover styles working at all. Works fine with other elements, but not this. Best I can do is get the background table to adopt the bg color i'd like, but not the button proper.

Code goes like this:

`

.hover:hover > * { background-color: blue!important; } Don't click me!

`

and then looks like this on hover:

Capture

any ideas?

iRyusa commented 5 years ago

You have to be a bit more specific about your css selector here : https://mjml.io/try-it-live/Hk_5ldOVr .hover:hover > * is not enough

m-gleeson commented 5 years ago

Thanks!

dylanmrowe commented 2 years ago

@iRyusa In the example you posted the button highlights when your mouse is anywhere on the row.

I've tried multiple ways to make it only highlight when on the button, but can't get it to work.

Any insight?

iRyusa commented 2 years ago

https://mjml.io/try-it-live/Hk_5ldOVr You only need to tweak the css selector.

dylanmrowe commented 2 years ago

This selector fixed it for me:

<mj-style> .hover p:hover { background-color: blue !important; } </mj-style>

Note that when I add a link to the button the \

tag changes to an \ tag.

ajaygharge-ds commented 1 year ago

<mj-button css-class="hover-blue" border-top="1px solid #000000" background-color="whitesmoke" color="black" mj-class="btn-10" align="center" href="https://www.apple.com"> Click Me! </mj-button>

if you have href attr in the button you can do hover by targeting "a"

.hover-blue:hover a {
        background-color: blue !important;
      }