Home > Web Front-end > CSS Tutorial > How to Make Navigation Bar List Items Fully Clickable?

How to Make Navigation Bar List Items Fully Clickable?

DDD
Release: 2024-10-30 07:10:03
Original
808 people have browsed it

How to Make Navigation Bar List Items Fully Clickable?

Making Navigation Bar List Items Fully Clickable

In a typical horizontal navigation bar created using an unordered list, clicking anywhere on a list item will most likely only trigger the action if the cursor is within the text of the link itself. To extend the clickable area to the entire list item, modify the HTML and CSS as follows:

CSS:

<code class="css">#nav li a {
  display: inline-block;
  padding: 25px 10px;
}</code>
Copy after login

By removing the padding from the 'li' elements and adding it to the anchor tags, the clickable area is now extended to fill the entire width and height of the list item.

HTML:

<code class="html"><div id="nav">
  <img src="/images/renderedicon.png" alt="Icon" height="57" width="57" />
  <ul>
    <li><a href="#">One1</a></li>
    <li><a href="#">Two</a></li>
    <li><a href="#">Three</a></li>
    <li><a href="#">Four</a></li>
  </ul>
</div></code>
Copy after login

Now, users can click anywhere within the list items to activate the corresponding links, providing a more user-friendly navigation bar.

The above is the detailed content of How to Make Navigation Bar List Items Fully Clickable?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template