HTML
代码语言:javascript复制<div class="mui-row">
<div class="mui-col-xs-6 mui-text-center" style="border-right: solid 1px #E5E5E5;">
<div><a href="javascript:void(0);" class="quick-shot">点此弹出modal</a></div>
</div>
<!-- modal -->
<div class="mui-col-xs-12 mui-text-centeri">
<div class="quick-shot-content">
<div class="quick-shot-img">
<img src="{{ empty($confuse->quick_shot) ? asset('/images/course_poster.jpg') : $confuse->quick_shot }}" width="100%">
</div>
</div>
</div>
</div>
<!-- 阴影遮挡部分 -->
<div class="shade"></div>
CSS
代码语言:javascript复制 .quick-shot-content {
display: none;
position: relative;
}
.quick-shot-img {
margin: auto;
position: absolute;
left: 0; bottom: 0; right: 0;
z-index: 9999;
}
.shade {
display: none;
top: 0;
left: 0;
background-color: #000;
opacity: 0.5;
filter: Alpha(opacity=0.2);
height: 100%;
width: 100%;
position: fixed;
z-index: 9998;
}
JS
代码语言:javascript复制 $(document).on('click', '.quick-shot', function(e){
$('.shade').fadeIn(300);
$(this).parent().parent().parent().find('.quick-shot-content').fadeIn(150);
stopPropagation(e);
});
function stopPropagation(e) {
if (e.stopPropagation)
e.stopPropagation();
else
e.cancelBubble = true;
}
$(document).ready(function(e) {
$(document).click(
function(e){
$('.shade').fadeOut(300);
$('.quick-shot-content').fadeOut(150);
}
);
});
结语
我是个前端渣渣,在使用MUI的时候找了好久他的modal,最后发现跟我的实现不一样,于是自己写了一个原生的。