【问题标题】:How to write :hover using inline style? [duplicate]如何编写 :hover 使用内联样式? [复制]
【发布时间】:2014-12-10 04:08:57
【问题描述】:
     <a href="#">Alink</a>

我需要的是,当我悬停时,链接的颜色应该改变,但它应该完全只使用内联 CSS

*无脚本或外部 CSS

请帮帮我。

【问题讨论】:

  • 我认为你可以实现它。在 html 中添加 类似这样的

标签: html css


【解决方案1】:

仅使用 CSS 不会发生

内联javascript

<a href='index.html' 
    onmouseover='this.style.textDecoration="none"' 
    onmouseout='this.style.textDecoration="underline"'>
    Click Me
</a>

working draft of the CSS2 spec 中声明您可以像这样使用内联伪类:

<a href="http://www.w3.org/Style/CSS"
   style="{color: blue; background: white}  /* a+=0 b+=0 c+=0 */
      :visited {color: green}           /* a+=0 b+=1 c+=0 */
      :hover {background: yellow}       /* a+=0 b+=1 c+=0 */
      :visited:hover {color: purple}    /* a+=0 b+=2 c+=0 */
     ">
</a>

但据我所知,它从未在规范的发布中实现。

http://www.w3.org/TR/2002/WD-css-style-attr-20020515#pseudo-rules

【讨论】:

    猜你喜欢
    • 2013-08-30
    • 2011-07-04
    • 2016-04-14
    • 1970-01-01
    • 2010-09-12
    • 2021-06-23
    • 1970-01-01
    • 2022-12-31
    • 1970-01-01
    相关资源
    最近更新 更多