代码之家  ›  专栏  ›  技术社区  ›  Joe F

悬停时字体颜色不变

  •  3
  • Joe F  · 技术社区  · 7 年前

    enter image description here

    现在,当我在上面悬停时,它看起来是这样的:

    enter image description here

    当我将鼠标悬停在文本上时,无法将其变为白色

    .button {
    	   border: 0px solid #011f4b;
    	   background: #011f4b;
    	   padding: 3px 21px;
    	   -webkit-border-radius: 16px;
    	   -moz-border-radius: 16px;
    	   border-radius: 16px;
    	   color: #ffffff;
    	   font-size: 12px;
    	   font-family: Questrial;
    	   text-decoration: none;
    	   vertical-align: middle;
    	   letter-spacing: 2px;
        }
       
       .button:hover {
    	   border: 0px solid #1292e1;
    	   background: #1292e1;
    	   color: white;
        }
       
       .button:active {
    	   background: #1292e1;
    	   color: #fff;
        }
    <a href='#' class='button'>Login</a>
    2 回复  |  直到 7 年前
        1
  •  3
  •   Atimene Nazim    7 年前

    尝试添加! !important

        2
  •  1
  •   Temani Afif    7 年前

    尝试添加 在选择器中添加标签,以避免与站点中的其他CSS冲突:

    a.button {
      border: 0px solid #011f4b;
      background: #011f4b;
      padding: 3px 21px;
      -webkit-border-radius: 16px;
      -moz-border-radius: 16px;
      border-radius: 16px;
      color: #ffffff;
      font-size: 12px;
      font-family: Questrial;
      text-decoration: none;
      vertical-align: middle;
      letter-spacing: 2px;
    }
    
    a.button:hover {
      border: 0px solid #1292e1;
      background: #1292e1;
      color: white;
    }
    
    a.button:active {
      background: #1292e1;
      color: #fff;
    }
    <a href='#' class='button'>Login</a>

    您也可以考虑 !重要的 要强制保持白色,请执行以下操作:

    a.button:hover {
          border: 0px solid #1292e1;
          background: #1292e1;
          color: white!important;
        }