Html 如何编写 :hover 使用内联样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26376496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:52:34  来源:igfitidea点击:

How to write :hover using inline style?

htmlcss

提问by manoji stack

     <a href="#">Alink</a>

All i need is while i hover the color should change for the link, But it should be completely using only inline CSS

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

*No Scripting or external CSS

*无脚本或外部CSS

Please help me out in this.

请帮我解决这个问题。

回答by davidcondrey

Not gonna happen with CSS only

仅使用 CSS 不会发生

Inline javascript

内联 JavaScript

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


In a working draft of the CSS2 spec it was declared that you could use pseudo-classes inline like this:

CSS2 规范工作草案中,声明您可以像这样内联使用伪类:

<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>

but it was never implemented in the release of the spec as far as I know.

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

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

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