How do I make an tag the size of it's parent
  • tag for larger clickable region?
  • 前端 未结 7 1397
    我在风中等你
    我在风中等你 2020-12-08 04:11

    I would like to do this so that the clickable region on the tag is size of the LI.

    My html looks like:

  • 7条回答
    •  春和景丽
      2020-12-08 04:47

      If you currently have this same question you can simply add padding to the right place:

      li {
        //remove any padding or margin attributes from here
      }
      
      li a {
        display: block;
        padding: 20px; //or however big you want the clickable area to be
      }
      

      Anchor tags are by default inline elements, so you have to explicitly change them to display as block elements before you can mess with the padding or the margins.

      Hope this helps!

    提交回复
    热议问题