html - 为什么悬停颜色不填充

标签 html css

我想要一个按钮,当我们将鼠标悬停在该按钮上时,填充白色并且里面的文本变为蓝色

这是该按钮的 HTML CSS

 .working-btn-white button {
  height:60px;
  width:155px;
  font-weight: bold;
  background: transparent;
  border-radius:30px;
  border:2px solid #fff;
  color:#fff;
  outline:none;
  position: relative;
  margin: 25px;
  overflow: hidden;
 }
 .working-btn-white button span {
  display: inline-block;
  height:100%;
  width:100%;
  line-height: 60px;
 }
 .working-btn-white button span:hover{
    color: #337ab7;
    font-weight: bold;

 }
 .working-btn-white button span::after {
  position: absolute;
  content:"";
  top:0;
  left:-100%;
  width:100%;
  height: 100%;
  background: #fff;
  transition:left 0.25s ease;
  z-index:-1
 }
 .working-btn-white button span:hover::after {
  left:0%;
  color:white;
 }


my html   

<div class="working-btn-white">
                <button><span>Get a Quote</span></button>
                <button><span>View our Work</span></button>
               </div>

但它不会在背景中填充白色,您可以在此处查看类似效果 https://codepen.io/anon/pen/BXoJbX但我需要白色而不是这种渐变填充

最佳答案

它不起作用,因为你的 z-index 属性在它上面不起作用,因为它是 position:absolute 所以你需要给你的父潜水作为不透明度小于一个(比方说.99)然后我认为它适用于你。您可以使用此链接进一步了解 https://philipwalton.com/articles/what-no-one-told-you-about-z-index/

关于html - 为什么悬停颜色不填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57254358/

相关文章:

html - Bootstrap Navbar 超宽错误

javascript - Ko Loadingwhen spinner Pointer 事件。

html - 即使在添加溢出 css 后,Div 也不可滚动

html - 我们可以将列表样式类型的列表设置为绿色点吗?

javascript - 如何使用 VANILLA JS 将类添加到嵌套的 Dom 元素

javascript - 使用 jquery mouseover 事件在单个元素中添加 2 个 css

javascript - 代码的样式问题

html - 如何防止 span 中的文本进入兄弟 span 中的内容?

php - 由操作系统引起的潜在网站错误?

css - chrome 中的 overflow-y phantom margin