简体   繁体   English

HTML5/CSS3 模态框与 IE 的兼容性

[英]HTML5/CSS3 Modal Box Compatibility with IE

I'm playing around with HTML5/CSS3 for the first time and have used a nice wee link to a dialog (modal) display on one of my pages.我第一次使用 HTML5/CSS3,并在我的一个页面上使用了一个很好的链接到对话框(模态)显示。

This works like a dream in Chrome/Firefox but not in IE (Possibly not a huge surprise).这在 Chrome/Firefox 中就像梦想一样工作,但在 IE 中却不是(可能不是一个巨大的惊喜)。

In IE (9) the page actually freezes entirely when trying to click on a link..在 IE (9) 中,当尝试点击链接时,页面实际上完全冻结。

Could anyone point out exactly what part of the CSS is incompatible and if there is a fix available?谁能指出 CSS 的哪一部分不兼容,以及是否有可用的修复程序?

Code is found below, thanks in advance.代码在下面找到,提前致谢。

HTML HTML

 <td><a href="#Code1">Get Date / Without Time</a></td>


 <div id="Code1" class="modalDialog">

 <div>

<a href="#close" title="Close" class="close">X</a>
<h2>TITLE</h2>
<p>TEXT</p>
        </div>
        </div>

CSS CSS

.modalDialog {
        position: fixed;
        font-family: "Trebuchet MS", Helvetica, sans-serif;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        overflow: auto;
        background: rgba(0,0,0,0.8);
        z-index: 99999;
        opacity:0;
        -webkit-transition: opacity 400ms ease-in;
        -moz-transition: opacity 400ms ease-in;
        transition: opacity 400ms ease-in;
        pointer-events: none;
    }

    .modalDialog:target {
        opacity:1;
        pointer-events: auto;
    }

    .modalDialog > div {
        width: 40%;
        height: auto;
        position: relative;
        margin: 10% auto;
        padding: 5px 20px 13px 20px;
        border-radius: 10px;
        background: #FFFFFF;
        background: -moz-linear-gradient(#FFFFFF, #999999);
        background: -webkit-linear-gradient(#FFFFFF, #999999);
        background: -o-linear-gradient(#FFFFFF, #999999);
    }

    .close {
        background: #285C82;
        color: #FFFFFF;
        line-height: 25px;
        position: absolute;
        right: -12px;
        text-align: center;
        top: -10px;
        width: 24px;
        text-decoration: none;
        font-weight: bold;
        -webkit-border-radius: 12px;
        -moz-border-radius: 12px;
        border-radius: 12px;
        -moz-box-shadow: 1px 1px 3px #000;
        -webkit-box-shadow: 1px 1px 3px #000;
        box-shadow: 1px 1px 3px #000;
    }

    .close:hover { color: #285C82; background: #FFFFFF; }

in all the tags where you wrote -webkit-, -moz- or -o- you didnt wrote -ms- which is the prefix for internet explorer.在你写 -webkit-、-moz- 或 -o- 的所有标签中,你没有写 -ms- 这是 Internet Explorer 的前缀。 transition doesnt work at internet explorer at all, you can see the internet explorer support in w3schools过渡在 Internet Explorer 中根本不起作用,您可以在w3school 中看到 Internet Explorer 支持

boaz波阿斯

IE9 does not support CSS pointer-events . IE9不支持CSS pointer-events In all browsers the dialog is invisibly (opaquely) rendered over the whole page but in IE9 the pointer events are not ignored and therefore the dialog is blocking the click event on the anchor.在所有浏览器中,对话框都在整个页面上不可见(不透明)呈现,但在 IE9 中,指针事件不会被忽略,因此对话框阻止了锚点上的点击事件。

There is probably a cleaner way to solve this but as a workaround you could add the following properties in a separate stylesheet for IE using conditional comments .可能有一种更简洁的方法来解决这个问题,但作为一种变通方法,您可以使用条件注释在 IE 的单独样式表中添加以下属性。

.modalDialog {
    display:none;
}

.modalDialog:target {
    display:block;
}

Another workaround is to give the <a> position and a z-index > the z-index of the dialog.另一种解决方法是给<a>位置和 z-index > 对话框的 z-index。

Also, CSS transition is not supported in IE9 so you might need to look for an alternative, maybe IE < 9 CSS3 Transition Effect Cheats?此外,IE9不支持CSS transition ,因此您可能需要寻找替代方案,也许IE < 9 CSS3 Transition Effect Cheats? will help.会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM