html - 我在 CSS 中只有一个类语句有效

标签 html css

我无法为我的 href 添加多功能。

这是我的代码:

HTML:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css-style.css">
         <title></title>
     </head>
     <body>
        <h1>Hello HTML!</h1>
        <p>I am Hristiqn. I am from <a class="magic" href="https://en.wikipedia.org/wiki/Neverland">Neverland</a></p>
    </body>
</html>

CSS:

a.magic:visited {font-size: 300px; 
  background: -webkit-linear-gradient(gold,green);
 -webkit-background-clip: text;
 -webkit-text-fill-color: transparent;}

 a.magic:active {font-size: 300px; 
  background: -webkit-linear-gradient(red,green);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;}

  a.magic:hover { font-size: 60px;
  background: -webkit-linear-gradient(white, green);
 -webkit-background-clip: text;
 -webkit-text-fill-color: transparent;}

现在我正在尝试通过将所需的样式属性设置为一个名为 magic 的类来做到这一点,但似乎只有 :hover 有效。 我尝试按名称设置属性,但效果是一样的 - 只有悬停有效。

所以我希望链接按钮在我将鼠标悬停在它上面时执行不同的操作,只要它处于事件状态等等,但似乎只有我的 :hover 语句有效,我不知道为什么。

谢谢。

最佳答案

我注意到你的 </a>被错误地关闭。尝试解决这个问题。

关于html - 我在 CSS 中只有一个类语句有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42577642/

相关文章:

html - 删除网络菜单中的第一个 child

html - 滚动时如何使页面的一部分固定在顶部

jquery - 使用 JQuery 为编辑器创建一个新的 "Scope"

javascript - 单击时删除附加的子项

javascript - 我有一个按钮,单击时会更改其中的文本,但不会改回

javascript - 为什么 window.location.href 再次附加 url

jquery - 从输入 [type=color] 更新显示颜色

html - 使用 CSS 将 HTML 元素相对于父元素的底部定位?

javascript - 应用并显示了 CSS 样式,但 JS 无法识别应用的 CSS

javascript - Google Apps 脚本使用函数写入 HTML