Make a div into a link

后端 未结 27 1700
栀梦
栀梦 2020-11-22 03:15

I have a

block with some fancy visual content that I don\'t want to change. I want to make it a clickable link.

I\'m looking for something l

27条回答
  •  臣服心动
    2020-11-22 04:14

    This option doesn’t require an empty.gif as in the most upvoted answer:

    HTML:

     

    CSS:

     div.feature {
            position: relative;
        }
    
        div.feature a {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            text-decoration: none; /* No underlines on the link */
            z-index: 10; /* Places the link above everything else in the div */
            background-color: #FFF; /* Fix to make div clickable in IE */
            opacity: 0; /* Fix to make div clickable in IE */
            filter: alpha(opacity=1); /* Fix to make div clickable in IE */
        }
    

    As proposed at http://www.digitalskydesign.com/how-to-make-an-entire-div-a-link-using-css/

提交回复
热议问题