body { Font-family: "Exo 2",sans-serif; margin: 0; padding: 0; justify-content: center; height: 100vh; align-items: center;}.active { text-decoration: none; color: #000; position: relative; padding: 8px 30px; background: #fff; text-transform: uppercase; Font-size: 15px; Box-sizing: border-Box; Transition: 0.5s; border: 2px solID #000;}.active:before { content: '' ; position: absolute; top: 0; left: 0; wIDth: 50%; height: 100%; background: #000; z-index: 1; transform: scaleX(0); Transition: transform 0.5s; transform-origin: left;}.active:hover { color: #fff;}.active:hover:before { transform: scaleX(1); Transition: transform 0.5s; transform-origin: right;}.active:after { content: '' ; position: absolute; top: 0; right: 0; wIDth: 50%; height: 100%; background: #000; z-index: 1; transform: scaleX(0); Transition: transform 0.5s; transform-origin: right;}.active:hover:after { transform: scaleX(1); Transition: transform 0.5s; transform-origin: left;}
<!DOCTYPE HTML><HTML lang="en"><head> <Meta charset="UTF-8"> <Meta name="vIEwport" content="wIDth=device-wIDth,initial-scale=1.0"></head><body> <a href="#">Login</a> </body></HTML>解决方法 您将元素放在具有该z-index值的文本之前.
基于您拥有的所有变体,还包括按钮的背景,我建议您使用< span>对于文本并在该元素上使用更高的z-index:
body { Font-family: sans-serif; margin: 30px; text-align: center;}.active { text-decoration: none; color: #000; position: relative; padding: 8px 30px; background: #fff; Font-size: 15px; Transition: 0.5s; border: 2px solID #000;}.active span { position: relative; Transition: color .3s linear; z-index: 2}.active:before,.active:after { content: ''; position: absolute; top: 0; left: 0; wIDth: 50%; height: 100%; background: #000; z-index: 1; transform: scaleX(0); Transition: transform 0.5s; transform-origin: left;}.active:after { left: auto; right: 0; transform-origin: right;}.active:hover span { color: #fff;}.active:hover:before,.active:hover:after { transform: scaleX(1); Transition: transform 0.5s;}
<a href="#"><span>LOGIN</span></a>总结
以上是内存溢出为你收集整理的html – 当我将鼠标悬停在它上面时,为什么我的按钮不起作用?全部内容,希望文章能够帮你解决html – 当我将鼠标悬停在它上面时,为什么我的按钮不起作用?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)