Make A List Item Clickable (HTML/CSS)

后端 未结 8 2025
北恋
北恋 2020-12-03 05:26

So I\'m trying to make each list-item on my site clickable but I\'m not sure what is the best way to do it. Please help me out.

So here is the relevant HTML:

8条回答
  •  情话喂你
    2020-12-03 06:06

    The key is to give the anchor links a display property of "block" and a width property of 100%.

    Making list-items clickable (example):

    HTML:

    
    

    CSS:

    ul {
      list-style-type: none;
      margin: 0;
      padding: 0;
    }
    ul li a {
      display: block;
      width: 100%;
      text-decoration: none;
      padding: 5px;
    }
    ul li a:hover {
      background-color: #ccc;
    }
    

提交回复
热议问题