I am messing around with web development, I have fallen into an issue with the hover section of CSS i cant get it to work on my site.
I did have this working when i had the navigation going vertical but then decided to have it horizontal instead which is where the issues started.
I have searched this on StackOverflow and have checked google but non of the solutions seem to help. Sorry if my code is a bit messy i will show you the sections that you need from the HTML and the CSS
HTML
<div id="nav">
<ul>
<li><a href="Home.html"><b><font size="5">Home</font></b></a></li>
<li><a href="About.html"><b><font size="5">About</font></b></a></li>
<li><a href="ContactUs.html"><b><font size="5">Contact Us</font></b></a></li>
</ul>
</div>
CSS
#nav {
/*width: 200px;*/
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background: linear-gradient(to bottom, white 10%, #2E3E9F 90%);
}
li{
float: left;
}
li a{
display: block;
background-color: white;
text-align: center;
color: grey;
padding: 14px 16px;
text-decoration: none;
border: 1px solid black;
}
li a:hover{
background-color: grey;
color: white;
}
Try this, its not great to use !important
though. (Chrome)
#nav { /*width: 200px;*/ } ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background: linear-gradient(to bottom, white 10%, #2E3E9F 90%); } li { float: left; } li a { display: block; background-color: white; text-align: center; color: grey; padding: 14px 16px; text-decoration: none; border: 1px solid black; } li a:hover { background-color: grey !important; color: white !important;
<div id="nav"> <ul> <li><a href="Home.html"><b><font size="5">Home</font></b></a></li> <li><a href="About.html"><b><font size="5">About</font></b></a></li> <li><a href="ContactUs.html"><b><font size="5">Contact Us</font></b></a></li> </ul> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.