简体   繁体   English

Ejs-如何将鼠标悬停在ejs文件中?

[英]Ejs - How can we hover in ejs file?

I want to implement a function. 我想实现一个功能。 My app is made in angularjs and nodejs. 我的应用是用angularjs和nodejs制作的。 I am sending an email, and in that email I have a button to click. 我正在发送电子邮件,在该电子邮件中,我有一个单击按钮。

<td style="padding-top:32px;" class="suggest-artist">
                    <a href="<%=url%>" style="border:solid 1px rgba(0,0,0,0.8); text-align:center; display:block; font-size:17px; text-decoration:none;
                        color:rgba(0,0,0,0.8); font-family:'SlateStd-Bk', 'Lucida Grande', 'Lucida Sans', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'; padding:27px 10px 22px;"
                        onMouseOver="bgChange('green')"
                        onMouseOut="bgChange('blue')">Suggest artists now</a>
        </td>

I want to change the background color on hover, but it seems like it does not work this way. 我想在悬停时更改背景颜色,但似乎这种方式不起作用。 I googled and tried to implement inline hover but it does not work either. 我用谷歌搜索并尝试实现内联悬停,但这也不起作用。 So I find this solution onmouseover and onmouseout but this does not work either. 所以我在onmouseoveronmouseout找到了这个解决方案,但这也不起作用。 I also tried to include an external CSS but it does not work. 我也尝试包括一个外部CSS,但是它不起作用。 What should i do? 我该怎么办?

In your inline style, you have color:rgba(0,0,0,0.8); color:rgba(0,0,0,0.8);联样式中,您具有color:rgba(0,0,0,0.8); which overrides the ability to change hover state on your link. 这将覆盖更改链接上的悬停状态的功能。

You can, but you don't need JS to change color on hover. 可以,但是不需要JS在悬停时更改颜色。 Use something like :hover - see below: 使用类似:hover东西-见下文:

 .suggest-artist__link:hover { color: green; } 
 <td style="padding-top:32px;" class="suggest-artist"> <a href="#" class="suggest-artist__link" style="border:solid 1px rgba(0,0,0,0.8); text-align:center; display:block; font-size:17px; text-decoration:none; font-family:'SlateStd-Bk', 'Lucida Grande', 'Lucida Sans', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'; padding:27px 10px 22px;">Suggest artists now</a> </td> 

EDIT: Sorry - you wanted background color, not link color...do this: 编辑:对不起-您想要背景颜色,而不是链接颜色...执行以下操作:

 .suggest-artist__link:hover { background-color: green; } 
 <td style="padding-top:32px;" class="suggest-artist"> <a href="#" class="suggest-artist__link" style="border:solid 1px rgba(0,0,0,0.8); text-align:center; display:block; font-size:17px; text-decoration:none; font-family:'SlateStd-Bk', 'Lucida Grande', 'Lucida Sans', 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'; padding:27px 10px 22px;">Suggest artists now</a> </td> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM