html - Internet Explorer 中的简单模式问题

标签 html css internet-explorer simplemodal

在使用简单模式和多个浏览器时遇到一个恼人的问题。我整理了一个示例来说明问题。当它在 Firefox 或 Chrome 中运行时,它工作正常。这是一个简单的链接,单击它会弹出一个简单的对话框。如果您单击"is"按钮,则会弹出一条警告,如果您单击“否”,对话框将关闭而不执行任何操作。在 Internet Explorer 中运行时会出现问题。在版本 9 中,对话框出现在页面内容的下方和左侧,而它应该出现在页面的中间。它还将光标更改为等待,然后挂起。在版本 8 中,对话框出现在相同的位置,但按钮是可单击的,并且对话框起作用 - 只是不在正确的位置。我查看了所有的 css,无法发现问题所在。任何帮助,将不胜感激。这是页面代码和 CSS:

HTML 标记

<div id='container'>
    <div id='content'>
        <div id='confirm-dialog'>
        <h1>Dialog Test</h1>
        <a href="#" class='confirm'>Click Me for Dialog</a><br />
    </div>
    <div id='confirm'>
        <div class='header'><span>Dialog Window</span></div>
        <div class='message'>
            <p>This is a dialog.</p>
            <p>There are many like it, but this one is mine.</p>
            <p>Got it?</p>
        </div>
        <div class='buttons'>
            <div class='no simplemodal-close'>No</div>
            <div class='yes'>Yes</div>
        </div>
    </div>
</div>

JS 标记:

jQuery(function ($) {
    $('#confirm-dialog input.confirm, #confirm-dialog a.confirm').click(function (e) {
        e.preventDefault();

        confirm("", function () {
            alert("You clicked YES");
        });
    });
});

function confirm(message, callback) {
    $('#confirm').modal({
        closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
        position: ["20%",],
        overlayId: 'confirm-overlay',
        containerId: 'confirm-container', 
        containerCss: {
                            height: 250,
                            width: 400,
                            backgroundColor: '#fff',
                            border: '3px solid #ccc'
                      },

        onShow: function (dialog) {
            var modal = this;

            $('.message', dialog.data[0]).append(message);

            $('.yes', dialog.data[0]).click(function () {
                if ($.isFunction(callback)) {
                    callback.apply();
                }
                modal.close(); 
            });
        }
    });
}

CSS 标记:

#confirm {display:none;}

/* Overlay */
#confirm-overlay {background-color:#eee; cursor:wait;}

/* Container */
#confirm-container {height:140px; width:420px; font: 16px/22px 'Trebuchet MS', Verdana, Arial; text-  align:left; background:#fff; border:2px solid #0F1F91;}
/* solid #336699; */
#confirm-container .header {height:30px; line-height:30px; width:100%;        background:url(../img/confirm/header.gif) repeat-x; color:#fff; font-weight:bold;}
#confirm-container .header span {padding-left:8px;}
#confirm-container .message {color:#333; font-size:14px; margin:0; padding:12px 4px 12px 8px;}
#confirm-container .buttons {line-height:26px; width:160px; float:right; padding:10px 8px 0;} 
#confirm-container .buttons div {float:right; margin-left:4px; height:26px; width:40px; color:#666; font-weight:bold; text-align:center; background:url(../img/confirm/button.gif) repeat-x; border:1px solid #bbb; cursor:pointer;} 
#confirm-container a.modal-close {margin-top:3px}
#confirm-container a.modal-close:link,
#confirm-container a.modal-close:active,
#confirm-container a.modal-close:visited {text-decoration:none; font-weight:bold; position:absolute; right:10px; top:2px; color:#fff;}
#confirm-container a.modal-close:hover {color:#ccc;}

最佳答案

在另一个线程中找到了答案 - 尽管在我发布之前进行了搜索,但该线程并没有出现在我的初始搜索中。

修复是更改以下内容:

containerCss: {
  height: 250,
  width: 400,
  backgroundColor: '#fff',
  border: '3px solid #ccc',
},

对此:

containerCss: {
  height: 250,
  width: 400,
  backgroundColor: '#fff',
  border: '3px solid #ccc',
  position: 'absolute', top: '0px'
},

关于html - Internet Explorer 中的简单模式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10740786/

相关文章:

javascript - 将类分配给 React 中自定义组件的外包装

javascript - 如何在另一个 html 页面中打开一个 html 页面作为弹出窗口

css - 这段 CSS 有什么作用?

javascript - 使用 Internet Explorer 更新 Kendo DropDownList 时出现问题

html - SVG 颜色只能在 firefox 中正确显示

css - 如何将标题从另一个标题移动 50px?

javascript - 将一行中的 4 列居中对齐并响应

jquery - Bootstrap 轮播图像未水平居中

html - 带有侧面可见幻灯片和自定义动画的 slider

internet-explorer - IE 切断文本的右侧