我有一個按鈕,里面有一個鏈接。當我將滑鼠懸停在按鈕上時,我希望按鈕的背景顏色和鏈接的文本顏色發生變化。但是,當我將滑鼠懸停在按鈕上時,我無法更改鏈接的顏色,只有當我將滑鼠懸停在鏈接上時。這就是我所擁有的。
button {
background-color: navy;
padding: 1%;
font-size: 16px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
border: 4px inset darkgrey;
}
button a {
color: white;
text-decoration: none;
font-weight: bold;
}
button a:hover {
color: navy;
}
button:hover {
background-color: white;
}
<button><a href="random.html">Lorem ipsum</a></button>
謝謝!
uj5u.com熱心網友回復:
它不是很復雜,就像禮物一樣!
button {
background-color: navy;
padding: 1%;
font-size: 16px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
border: 4px inset darkgrey;
}
button a {
color: white;
text-decoration: none;
font-weight: bold;
}
button:hover {
background-color: white;
}
button:hover a {
color: navy;
}
<button><a href="random.html">Lorem ipsum</a></button>
uj5u.com熱心網友回復:
有人回答并洗掉了它,但它有效:
button:hover a {
color: navy;
}
uj5u.com熱心網友回復:
正如其他用戶所說,您不應該在按鈕內放置鏈接。如果您需要按鈕來打開另一個頁面,您可以將按鈕放在表單中并在操作上指定目標,如下所示:
<form action="random.html">
<button>Lorem ipsum</button>
</form>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/437800.html
上一篇:如何按值洗掉HTML表格行
