position绝对定位后,a中使用display:block 无效的解决办法
问题:
当一个div(a)采用了相对定位后,然后另外一个div(b)被div(a)包裹并绝对定位,在div(b)中的a,使其成块元素后在浏览器上成无效链接,鼠标指针无法自动成为手势指针,而且点击无反应。css如下:
.headtop{
position:relative;
z-index: 102;
height: 150px;
overflow: hidden;
}
.headtop .dzbutton{
position:absolute;
width:150px;height:26px;
overflow:hidden;
bottom:50px;
right:0;
z-index: 103;
}
.headtop .dzbutton .dzb1 a{
width:26px;height:26px;
display:block;
background:#ccc;
}
解决方案:
增加一个img标签,链接至一个透明gif文件 ,如下:
.headtop .dzbutton .dzb1 a img{
width:26px;height:26px;
}
div如下:
<div class="dzb1"><a href="#"><img src="assets/images/blank.gif" /></a></div>
这样a的宽高度就能达到自己预想的情况,并且有正常的链接。

浙公网安备 33010602011771号