我已经阅读了Magnific Popup的文档,其中包含了文件,只是根据以下内容复制并粘贴了模式弹出窗口中的代码 JsFiddle
<a class="popup-modal" href="#test-modal">Open modal</a>
<div id="test-modal" class="mfp-hide white-popup-block">
<h1>Modal dialog</h1>
<p>You won't be able to dismiss this by usual means (escape or click button), but you can close it programatically based on user choices or actions.</p>
<p><a class="popup-modal-dismiss" href="#">Dismiss</a>
</p>
</div>
$(document).ready(function () {
$('.popup-modal').magnificPopup({
type: 'inline',
preloader: false,
focus: '#username',
modal: true
});
$(document).on('click', '.popup-modal-dismiss', function (e) {
e.preventDefault();
$.magnificPopup.close();
});
});
但这根本不起作用,上面的代码出了什么问题?
答案 0 :(得分:1)
您的JsFiddle中可能存在外部加载的CSS问题。尝试删除外部加载的CSS并将内容粘贴到CSS选项卡中。