Making the clickable area of in-line links bigger without affecting the layout

前端 未结 5 801
滥情空心
滥情空心 2021-02-05 16:49

I\'m looking to make the clickable area of links bigger than they actually are for accessibility since for the intended users it can be difficult to hit them. About 1.5x the siz

5条回答
  •  梦毁少年i
    2021-02-05 17:12

    One option that might work is to use the :after pseudo-element. Something like this:

    a {
        position: relative
    }
    .bigger:after{
        content:"";
        padding: 50px;  
        position: absolute;
        left: -25px;
        top: -25px;
    } 
    

    Numbers could be tweaked as you like. Only downside I can see right away is if you need to support anything pre-IE8. http://caniuse.com/#feat=css-gencontent

    Here's a fiddle.

提交回复
热议问题