CSS按钮悬停 – 更改白色文本

huangapple go评论120阅读模式
英文:

CSS Button Hover - Change White Text

问题

.btn-orange a{
    color:#ffffff !important;
    text-decoration: none;
  }
  
 .btn-orange a:hover{
    color:#f2a152 !important;
  }
  .btn-orange a:visited{
    color:#ffffff;
    }
<button class="btn-orange"><a href="https://www.orcad.com/contact-us?utm_source=uberflip&amp;amp;utm_medium=cta&amp;amp;utm_campaign=contact">Contact Us</a></button>
英文:

Problem: When you hover over the box the box turns orange but the link text does not. What changes do I need to make to the CSS styles below for the link text to change to orange when you hover over the button box.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.btn-orange a{
    color:#ffffff !important;
    text-decoration: none;
  }
  
 .btn-orange a:hover{
    color:#f2a152 !important;
  }
  .btn-orange a:visited{
    color:#ffffff;
    }
    
.btn-orange{
font-family: Roboto, sans-serif;
font-weight: 0;
font-size: 16px;
color: #ffffff !important;
background-color: #f2a152;
padding: 15px 35px;
border: solid #f2a152 1px;
box-shadow: rgb(0, 0, 0) 0px 0px 0px 0px;
border-radius: 1px;
transform: translateY(0);
display: flex;
flex-direction: row;
align-items: center;
cursor: pointer;
}

.btn-orange:hover{
background-color: #fff;
color: #f2a152 !important;
border: solid 1px #f2a152;
}

<!-- language: lang-html -->

&lt;button class=&quot;btn-orange&quot;&gt;&lt;a href=&quot;https://www.orcad.com/contact-us?utm_source=uberflip&amp;amp;utm_medium=cta&amp;amp;utm_campaign=contact&quot;&gt;Contact Us&lt;/a&gt;&lt;/button&gt;

<!-- end snippet -->

答案1

得分: 1

你可以尝试将你的代码从

.btn-orange a:hover{
    color:#f2a152;
  }

修改为

.btn-orange:hover a{
    color:#f2a152;
  }
英文:

You can try changing your code from

.btn-orange a:hover{
    color:#f2a152;
  }

to

.btn-orange:hover a{
    color:#f2a152;
  }

答案2

得分: 1

你不能用按钮包装一个锚点。你可以使用其中一个。

我已根据您的要求更改了您的CSS和HTML。

<a class="btn-orange" href="https://www.orcad.com/contact-us?utm_source=uberflip&amp;utm_medium=cta&amp;utm_campaign=contact">联系我们</a>
英文:

You can't wrap an anchor with a button. You can use one or the either.

I changed your CSS and HTML accordingly.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.btn-orange:visited {
  color: #ffffff;
}

.btn-orange {
  font-family: Roboto, sans-serif;
  font-weight: 0;
  font-size: 16px;
  color: #ffffff !important;
  background-color: #f2a152;
  padding: 15px 35px;
  border: solid #f2a152 1px;
  box-shadow: rgb(0, 0, 0) 0px 0px 0px 0px;
  border-radius: 1px;
  transform: translateY(0);
  cursor: pointer;
  
  color: #ffffff !important;
  text-decoration: none;
  display:inline-block
}

.btn-orange:hover {
  background-color: #fff;
  color: #f2a152 !important;
  border: solid 1px #f2a152;
}

<!-- language: lang-html -->

&lt;a class=&quot;btn-orange&quot; href=&quot;https://www.orcad.com/contact-us?utm_source=uberflip&amp;amp;utm_medium=cta&amp;amp;utm_campaign=contact&quot;&gt;Contact Us&lt;/a&gt;

<!-- end snippet -->

答案3

得分: 0

将这部分内容翻译为:

.btn-orange:hover a{
    color:#f2a152;
  }
英文:

Change this

.btn-orange a:hover{
    color:#f2a152;
  }

to this

  .btn-orange:hover a{
    color:#f2a152;
  }

huangapple
  • 本文由 发表于 2023年6月16日 04:52:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76485441.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定