绝对定位下<a>标签无法点击

z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。

注释:元素可拥有负的 z-index 属性值。

注释:Z-index 仅能在定位元素上奏效(例如 position:absolute;)!

设置标签所在的盒子拥有更高的堆叠顺序
例如

在这里插入图片描述

<!DOCTYPE html> <html> <head> <title>网站首页</title> <meta charset="utf-8"> <style type="text/css"> *{ margin: 0 0; padding: 0 0; } /* 导航栏样式 */ ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a { display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } li a:hover { background-color: #111; } .login{ float: right; } /* 轮播图样式 */ .slideshow-container { position: absolute; top: 68px; left: 360px; margin: auto; height: 500px; width: 800px; } .mySlides { position: absolute; top: 0; left: 0; width: 800px; height: 500px; } .prev, .next { position: absolute; top: 50%; font-size: 30px; font-weight: bold; padding: 10px; cursor: pointer; z-index: 1; } .prev { left: 0; color: aliceblue; background-color:rgba(105,105,105,0.8); user-select: none; } .prev:active{ transform: scale(0.8); } .next:active{ transform: scale(0.8); } .next { right: 0; color: aliceblue; background-color:rgba(105,105,105,0.8); user-select: none; } img{ height: 500px; width: 800px; } </style> <script src="js/jquery-1.12.4.js"></script> <script> var index=1; $(function(){ $('.prev').click(function(){ index--; if(index<1) index=3; $('#pic').attr('src','../images/0'+index+'.jpg'); }) $('.next').click(function(){ next() }) window.setInterval("next()",2500) $('.prev').mouseover(function(){ $(this).css('color','#000') $(this).css('background-color','rgba(105,105,105,0.5)') }).mouseout(function(){ $(this).css('color','') $(this).css('background-color','') }) $('.next').mouseover(function(){ $(this).css('color','#000') $(this).css('background-color','rgba(105,105,105,0.5)') }).mouseout(function(){ $(this).css('color','') $(this).css('background-color','') }) }) function next(){ index++; if(index>3) index=1; $('#pic').attr('src','../images/0'+index+'.jpg'); } </script> </head> <body> <!-- 导航栏 --> <ul> <li><a class="active" href="#home">首页</a></li> <li><a href="#news">新闻</a></li> <li><a href="#contact">大唐不夜城</a></li> <li><a href="#about">展点信息</a></li> <li class="login"><a href="#">登录</a></li> </ul> <!-- 轮播图 --> <div class="slideshow-container"> <div class="mySlides"> <img src="../images/01.jpg" alt="" id="pic"> </div> <a class="prev">❮</a> <a class="next">❯</a> </div> </body> </html>
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值