Rumah  >  Artikel  >  hujung hadapan web  >  这是IE Bug谁有解决办法?_html/css_WEB-ITnose

这是IE Bug谁有解决办法?_html/css_WEB-ITnose

WBOY
WBOYasal
2016-06-24 11:43:23866semak imbas

下边的代码:box-button和box-cover都是绝对定位。box-cover是悬浮在box-button之上的,完全遮盖了box-button。box-cover绑定了click事件。box-button里面有文字,如果鼠标点击的区域没有文字,一切正常,但是如果点击在文字上,click事件就无效。当然只是在IE里面,我的是IE 10,大家有没有遇到过这种问题?请问怎么解决?

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        .box { position:relative; width:500px; margin:30px auto; }        .box * { position:absolute; top:0; right:0; width:100px; height:35px; }        .box .box-button { background-color:red; color:#FFF; line-height:30px; text-align:center; font-size:14px; }        .box .box-cover { z-index:100; cursor:pointer; }    </style>    <script type="text/javascript">        function docLoad() {            document.getElementById("cover").attachEvent("onclick", function () {                alert("OK");            });        }    </script></head><body onload="docLoad()">    <div class="box">        <div class="box-button">选择</div>        <div class="box-cover" id="cover"></div>    </div></body></html>


回复讨论(解决方案)

直接用box-button绑定相关事件不就可以了嘛。。。

直接用box-button绑定相关事件不就可以了嘛。。。



不行,其实这只是个例子,真正的情况不是这样的。真正的情况是我的box-cover里面其实是放了flash的。click事件是由flash响应的。

那就用透明呗:

      .box .box-cover { z-index:100; cursor:pointer;background:yellow;filter:alpha(opacity=0.1);	-moz-opacity:0.1;	-khtml-opacity: 0.1;	opacity: 0.1;}

那就用透明呗:

      .box .box-cover { z-index:100; cursor:pointer;background:yellow;filter:alpha(opacity=0.1);	-moz-opacity:0.1;	-khtml-opacity: 0.1;	opacity: 0.1;}



本来就是透明的。。这个跟透明没什么关系吧??


那就用透明呗:

      .box .box-cover { z-index:100; cursor:pointer;background:yellow;filter:alpha(opacity=0.1);	-moz-opacity:0.1;	-khtml-opacity: 0.1;	opacity: 0.1;}



本来就是透明的。。这个跟透明没什么关系吧??

div本身不是透明的

那就直接用div上的onclick实现就好了呗。。。

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        .box { position:relative; width:500px; margin:30px auto; }        .box * { position:absolute; top:0; right:0; width:100px; height:35px; }        .box .box-button { background-color:red; color:#FFF; line-height:30px; text-align:center; font-size:14px; }        .box .box-cover { z-index:100; cursor:pointer; }    </style>    <script type="text/javascript">		function aa(){			alert("OK");		}    </script></head><body onload="docLoad()">    <div class="box">        <div class="box-button">选择</div>        <div class="box-cover" id="cover" onclick="aa()"></div>    </div></body></html>

<style type="text/css">    #cover {        background-color: green;        filter:alpha(opacity=0);     }</style>

给 “cover” 一个背景色,让他完全遮住按钮;然后使其完全透明,把按钮的样式露出来。
这样就能解决你的问题。

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn