通过重叠项目管理Click事件(Manage Click events through overlapping items)

编程入门 行业动态 更新时间:2024-10-11 23:27:08
通过重叠项目管理Click事件(Manage Click events through overlapping items)

我在幻灯片组件中遇到了javascript重叠问题。 我想添加一个图标来删除幻灯片中的图片,此图标位于每张图片的右上角。

问题是:图标(和他的点击事件)位于一个大的空白div下(截图中为蓝色)。 这个div用于转到下一张图片。

是否有解决方案来触发图标事件并阻止幻灯片事件?

I got a javascript overlapping problem in a slideshow component. I want to add a icon to delete a picture in the slideshow, this icon is on the right top corner of each picture.

The problem is : The icon (and his click event) is under a big blank div (in blue on the screenshot). This div is used to go to the next picture.

Is there a solution to fire the icon event & block the slideshow event?

最满意答案

这是干净的代码

<html> <head> <style> #slideshowController1 { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; z-index: 98; border: 1px solid blue; } #slideshowController2 { position: absolute; left: 0; top: 0; width: 50%; height: 100%; z-index: 98; border: 1px solid green; } #pic1 { height: 400px; width: 400px; border: 1px solid red; } #delete1 { float: right; width: 24px; height: 24px; margin-top: 0px; background-color: black; } .swipe { overflow: hidden; visibility: hidden; position: relative; width: 100%; max-width: 500px; margin: 0 auto; text-align: center; } .swipe-wrap { overflow: hidden; position: relative; } #slideShow { position: relative; overflow: hidden; margin-top: 20px; } </style> </head> <body> <div id="slideShow"> <div id="slideshowController1" class="slideshowController" onclick="alert('right');"> </div> <div id="slideshowController2" class="slideshowController" onclick="alert('left');"> </div> <div id="mySwipe" class="swipe" style="visibility: visible;"> <div class="swipe-wrap" id="swipe-gallery" style="width: 2500px;"> <div id="pic1"> <div id="delete1" class="thumbDelete" style="z-index: 100;" onclick="alert('delete');"> <img src="../../img/delete.png" width="100%"> </div> </div> </div> </div> </div> </div> </body> </html>

如果我把z-index:100放在mySwipe上,它的工作只是在图片的一侧......它是一个部分解决方案!

但这不是理想的操作,只有图标必须结束......

有任何想法吗 ?

Here is the clean code

<html> <head> <style> #slideshowController1 { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; z-index: 98; border: 1px solid blue; } #slideshowController2 { position: absolute; left: 0; top: 0; width: 50%; height: 100%; z-index: 98; border: 1px solid green; } #pic1 { height: 400px; width: 400px; border: 1px solid red; } #delete1 { float: right; width: 24px; height: 24px; margin-top: 0px; background-color: black; } .swipe { overflow: hidden; visibility: hidden; position: relative; width: 100%; max-width: 500px; margin: 0 auto; text-align: center; } .swipe-wrap { overflow: hidden; position: relative; } #slideShow { position: relative; overflow: hidden; margin-top: 20px; } </style> </head> <body> <div id="slideShow"> <div id="slideshowController1" class="slideshowController" onclick="alert('right');"> </div> <div id="slideshowController2" class="slideshowController" onclick="alert('left');"> </div> <div id="mySwipe" class="swipe" style="visibility: visible;"> <div class="swipe-wrap" id="swipe-gallery" style="width: 2500px;"> <div id="pic1"> <div id="delete1" class="thumbDelete" style="z-index: 100;" onclick="alert('delete');"> <img src="../../img/delete.png" width="100%"> </div> </div> </div> </div> </div> </div> </body> </html>

if I put z-index:100 on mySwipe, it's work but only out side of the picture... its a partial solution !

But this is not the desired operation, only the icon must be over...

Any ideas ?

更多推荐

本文发布于:2023-08-07 03:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1460664.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目管理   事件   Click   Manage   overlapping

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!