html - 悬停时的变换按钮
问题描述
我正在尝试在 html 和 css 中实现效果。我有一个按钮,上面写着“登录”。所以我想做的是当我悬停时:
登录按钮变成两个按钮,上面写着:
“客户登录”和“管理员登录”。
解决方案
这是一种用一些简单的css制作的方法;
.login-actions { position: relative; }
.login-actions a { display: inline-block; padding: 1rem 2rem; text-decoration: none; color: #fff; background: #111; }
.login-actions a:not(:first-child) { opacity: 0; }
.login-actions:hover a:not(:first-child) { opacity: 1; }
.login-actions:hover a:first-child { opacity: 0; position: absolute; left:0; top: 0; z-index: -1; }
<div class="login-actions">
<a href="#">Login</a>
<a href="#">Customer Login</a>
<a href="#">Admin Login</a>
</div>
推荐阅读
- bash - 我正在尝试交换用户输入的字符串
- arrays - 从 json 响应中获取前两个索引的数据
- javascript - js代码相似的多个表单域如何控制
- angular - PrimeNg P-dropdown 获取和设置值详细信息?
- python - 从一列中删除与另一列中的值相等的值
- api - Zapier基本身份验证传递空白数据
- java - 我希望这种方法能够在毫秒内转换并获得价值
- node.js - 网络抓取图像的 reddit subreddit 是否合法?
- groovy - Groovy 脚本中的 JsonSlurper parseText 异常:java.lang.ClassCastException:[B 无法转换为 [C
- c++ - 有没有办法在 C++ 中并行遍历向量的所有元素?