使整个div成为超链接

时间:2015-02-05 21:39:39

标签: html css hyperlink

如何将整个pad div区域变为超链接?

http://jsfiddle.net/obxh7qpn/

这是我的HTML:

    <div class="pad">
    <div href="http://www.google.com" style="height:286px;width:286px;background:url('http://placehold.it/1x1') top center no-repeat;background-size:cover">
        <div>
            <span>View all</span>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:3)

<a href='http://www.google.com'>
<div class="pad">
    <div style="height:286px;width:286px;background:url('http://placehold.it/1x1') top center no-repeat;background-size:cover">
        <div>
            <span>View all</span>
        </div>
    </div>
</div>
</a>

围绕整个事物包装标签!

答案 1 :(得分:2)

使用&#34; onclick =&#34;事件而不是href

<div onclick="document.location='http://www.google.com'> ...