Reputation: 1531
Please take a look at this:
This is my html:
<nav id="mainNav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="projects.html">Our Projects</a></li>
<li><a href="team.html">Our Team</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
And my css:
#mainNav ul li {
padding-left: 10px;
}
#mainNav ul li:hover {
background-color: rgba(0,0,0,.2);
color: #fff;
cursor: pointer;
}
The links are activated only when I place the cursor above the text's link and click. I would like to able to click anywhere inside the darker "li"'s background and activate the corresponding link. How is this possible?
Upvotes: 0
Views: 2371
Reputation: 4723
It is only possible to click on the link(text) because the <a>
has the height and width of the font, not from the <li>
. If you want to be able to click on the full <li>
you can use something like this.
Set the <a>
around the <li>
.
Example:
<a href="index.html"><li>Home</li></a>
Updated with a demo:
Upvotes: 2
Reputation: 11
You can try it like this:
<li onclick="location.href='index.html'">Home</li>
Upvotes: 1