【问题标题】:How do I make the link and the div element activate at the same time如何让链接和 div 元素同时激活
【发布时间】:2022-11-20 18:37:37
【问题描述】:

当我将鼠标悬停在 div 元素上时,只有它亮起而不是链接。 有什么办法可以让按钮亮起来,而不是按钮背景,然后是链接。

<div id="b1"; class = b>
    <a href="test.html">BUY</a>
</div>

<div id="b2"; class = b>
    <a href="test.html">BUY</a>
</div>

<div id="b3"; class = b>
    <a href="test.html">BUY</a>
</div>
a:visited{
    color: white
}
a:hover:visited{
    color: rgb(180, 179, 179);
}

a:link{
    color: white;
    background-color:  rgb(180, 179, 179);
}
a:hover{
    color: rgb(180, 179, 179);   
    background-color: white    
}

div.b{
    color:  white;
    background-color: rgb(180, 179, 179);
}

div.b:hover{
    color: rgb(180, 179, 179);   
    background-color: white    
}
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:active { text-decoration: none; }

我尝试了至少我知道的一切

【问题讨论】:

    标签: html css button hover


    【解决方案1】:

    试试看

    .b:hover {
      background: #ccc;
    }
    
    .b:hover a {
      background: green;
    }
    
    /* or */
    .b a:hover {
      color: red;
    }
    

    https://codepen.io/roma3z/pen/QWxapdB

    【讨论】:

      猜你喜欢
      • 2019-07-22
      • 1970-01-01
      • 2015-04-23
      • 2017-10-30
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      相关资源
      最近更新 更多