简洁的模态框

本文共有3072个字,关键词:

简介:简单的模态框代码

HTML:

<!-- 弹窗 -->
<div class="backdrop"></div>
<div class="modal-box" id="folder_modal">
    <div class="modal-content">
        <div class="modal-header">
            <label class="modal-title">移动到</label>
            <i class="fr modal-close fa fa-close"></i>
        </div>
        <div class="modal-body">
        </div>
        <div class="modal-footer">
            <button type="button" class="mt-button" id="submit_btn">确定</button>
            <button type="button" class="mt-button-light" id="cancel_btn">取消</button>
        </div>
    </div>
</div>

JS:

// 移动文件
$('.move_btn').on('click',function(){
    $('body').addClass('hidden').css('padding-right','17px');
    $('.backdrop').fadeIn();
    $('.modal-box').fadeIn();
});
// 关闭弹窗
$('.modal-close, .modal-box, #cancel-btn').on('click', function(){
    $('.modal-box').fadeOut(function(){
        $('body').removeClass('hidden').css('padding-right','0');
        $('.backdrop').fadeOut();
    });
});
$('.modal-content').on('click', function(e){
    e.stopPropagation();
});

CSS:

/**
 * 模态窗样式
 * by wang 201607
 */
/* modal样式 */
.backdrop{
    background-color:#000;
    position:fixed;
    top:0;
    right:0;
    bottom:0;
    left:0;
    opacity:0.5;
    z-index:1000;
    display:none;
}
.modal-box{
    position:fixed;
    top:0;
    right:0;
    bottom:0;
    left:0;
    z-index:1010;
    overflow-y:auto;
    overflow-x:hidden;
    display:none;
}
.modal-content{
    position:relative;
    margin:30px auto;
    background-clip:padding-box;
    background-color:#fff;
    border:1px solid #666;
    box-shadow:0 5px 15px #000;
    border-radius:6px;
}
.modal-header{
    border-bottom:1px solid #ddd;
}
.modal-title{
    display:inline-block;
    font-weight:bold;
    padding:15px 20px 10px;
}
.modal-close{
    padding:20px 20px 0;
    cursor:pointer;
}
.modal-body{
    padding:5px 20px;
}
.modal-footer{
    padding:5px 20px 15px;
}
/* 弹窗样式补充 */
.mt-button{
  color:#fff;
  background-color:#1E9FFF;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  padding: 5px 12px;
}
.mt-button:hover{
  opacity:.8;
}
.mt-button-light{
  color:#1E9FFF;
  background-color:#fff;
  border: 1px solid #1E9FFF;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
  padding: 5px 12px;
}
.mt-button-light:hover{
  background-color:#fafafa;
}
.modal-content{
  width:800px;
}
版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。
添加新评论
暂无评论