javascript - 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
解决方案
只需使用:hover
CSS 伪类和text-decoration
CSS 属性。
而且,真的,如果你只想要文本而不是真正制作 clickable button
,你可以使用几乎任何元素,但是 adiv
允许你删除所有你必须使按钮看起来不像按钮的样式。
body { background-color: black }
div { color: white; cursor:pointer; }
div:hover { text-decoration:line-through; }
<div>Hello</div>
推荐阅读
- javascript - 你如何处理 React 中嵌入文档的 500 错误?
- unity3d - 如何使用相同的鼠标按钮选择另一个游戏对象(第一次选择!= null?)?在统一
- php - Laravel - 获取关系中的选定列
- ruby - Ruby Selenium - 警告 :driver_path 已弃用
- python - 创建代码后如何创建自己的 pip 安装模块?
- ios - 如何在 iOS 应用中使用 swift 进行 gRPC 调用
- php - 如何用相同的ajax比较两个值?
- javascript - 使用 React 功能组件重定向
- mysql - 如何使数据库可移植
- c# - 使用 sql 出现错误“输入字符串的格式不正确”