让整个div可点击 [英] Make a whole div clickable

查看:115
本文介绍了让整个div可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div内的链接,我需要使整个div可点击...在Internet上找到几个教程,但其中没有一个适合我...

I have a link inside a div and I need to make the whole div clickable... found several tutorials on the Internet but non of them worked for me...

推荐答案

如果你想让整个div可点击进行导航,那么你可以用一个不符合标准的anchor()标签包装它,或者添加一个CSS样式到包含的锚标签,使其成为包含div的大小,这符合标准。在这个例子中,我将使用一个250像素×250像素的div:

If you're saying you want the entire div to be clickable for navigation, then you can either wrap it with an anchor () tag, which is not standards compliant, or add a css style to the contained anchor tag, making it the size of the containing div, which is standards compliant. I will use a div that is 250px by 250px in this example:

<div id="container"><a href="" style="display:block;width:250px;height:250px;">Link</a></div>

这篇关于让整个div可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆