Recently, I encountered a challenge while working on my website. I want to set up a link inside a div that changes color when hovered over. However, the desired effect is not quite coming out as expected. Before hovering, I aim to have a border around the div matching the color of the text in the link. The background should be white. Upon hover, the background must shift to the color of the text and border, with the text turning white. Unfortunately, due to the padding between the link and div border, the outcome is not ideal. Here is the source code in HTML/CSS:
HTML:
<div id="home">
<a href="index.html">HOME</a>
</div>
CSS:
#home {
border: 4px solid #00a651;
font-size: 30px;
padding: 10px 20px 10px 20px;
margin: 20px 100px 20px 100px;
display: inline-block;
}
#home a {
background: #ffffff;
color: #00a651;
text-align: center;
}
#home a:hover {
background: #00a651;
color: #ffffff;
}
Upon hover, only the link changes color while the padding stays white when the cursor hovers over the link or anywhere else within the div. How can I adjust the code so the color changes take place when any part of the div is hovered over, and the entire div shifts colors? Your help would be greatly appreciated. Thank you, Brandon :)