繁体   English   中英

悬停更改背景颜色但不更改文本颜色

[英]Hover change background color but not change the text a color

这是我的代码,悬停时我只能更改“ popup1_btn”按钮的颜色,但文本颜色无法更改。 如果使用.popup1_btn a:hover ,则仅更改文本的背景颜色和文本颜色,而不更改整个按钮的背景颜色。

HTML

<div id="myModal" class="modal home-modal">

  <!-- Modal content -->
  <div class="modal-content">
     <div class="get_free_modal">
       <div class="modal_top_logo">
          <img src="http://example.jpg">
       </div>
       <a href="javascript:void(0)" title="Close" class="modal-close close"><img src="http://example.png"></a>
       <div class="modal_inner_contant">
         <div class="third_modalImg">
            <img src="http://example.jpg">
         </div>
      </div>

      <div class="popup1_btn">
         <a href="http://example.com/">I'm Interested</a>
      </div>

    </div>
  </div>

</div>

CSS:

.popup1_btn {
    width: 210px;
    height: 45px;
    font-size: 20px;
    text-transform: uppercase;
    background-color: #d3db2c;
    color: black;
    cursor: pointer;
    margin: 30px auto 0;
    line-height: 45px;
    font-family:"Avant Garde Demi BT";
}

.popup1_btn:hover {
    background-color: black;
    color: #d3db2c;
 }

您需要使用

.popup1_btn:hover a {...}

 .popup1_btn { width: 210px; height: 45px; font-size: 20px; text-transform: uppercase; background-color: #d3db2c; color: black; cursor: pointer; margin: 30px auto 0; line-height: 45px; font-family:"Avant Garde Demi BT";} .popup1_btn:hover{ background-color: black; } .popup1_btn:hover a { color: #d3db2c; } 
 <div class="popup1_btn"><a href="http://example.com/">I'm Interested</a></div> 

您应该添加代码行。

 .popup1_btn:hover a {
   color: #ffffff;
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM