首页 > 解决方案 > how to strike out text when a user hovers over it

问题描述

When a user hovers over a button I want to strike out the text.

Here is what I have so far:

button{  background-color: Transparent;
  background-repeat:no-repeat;
  border: none;
  cursor:pointer;
  overflow: hidden;
  outline:none;
  color: white;
}

body{
background-color: black
}
<button>Hello</button>

Any suggestion please

标签: javascripthtmlcss

解决方案


只需使用:hoverCSS 伪类text-decorationCSS 属性

而且,真的,如果你只想要文本而不是真正制作 clickable button,你可以使用几乎任何元素,但是 adiv允许你删除所有你必须使按钮看起来不像按钮的样式。

body { background-color: black }
div { color: white; cursor:pointer; }
div:hover { text-decoration:line-through; }
<div>Hello</div>


推荐阅读