我有 div2(height 20px vertical align center)
inside div1(100px)
和 div2 having anchor tag.
悬停在 div1
上时,我正在显示手形指针,但也希望在 div1
区域中的任意位置单击它应该导航到 anchor 标记 url。详情请引用图片
.test:hover {
cursor: pointer;
cursor: hand;
}
<div class="test" style="height:100px">
<div style=" position: relative; top: 50%; transform: translateY(-50%);">
<a href="google.com" ; target="_blank" title="This link opens in a new window" style="color:#2e3940;text-decoration: initial;">Pawan Kotak</a>
</div>
</div>
最佳答案
如果外部“div”应该表现得像一个 anchor ,只需像这样重新排列元素:
<a href="myAnchor.tld">
<div id="div1">
<div id="div2"></div>
</div>
</a>
如果您的标记可以简单地按照实际工作的方式构建,您就不必乱用 jQuery。
关于javascript - Div 悬停指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40863101/