Bootstrap自定义模态窗口样式

当前位置:主页 > CSS3库 > UI界面设计 > Bootstrap自定义模态窗口样式
Bootstrap自定义模态窗口样式
分享:

    插件介绍

    这是一款Bootstrap自定义模态窗口样式。高模态窗口通过简单的CSS代码,将原生的bootstrap模态窗口进行美化。

    浏览器兼容性

    浏览器兼容性
    时间:2019-05-28
    阅读:
简要教程

这是一款Bootstrap自定义模态窗口样式。高模态窗口通过简单的CSS代码,将原生的bootstrap模态窗口进行美化。

使用方法

在页面中引入下面的文件。

<link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
                
HTML结构
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="modal-box">
                <!-- Button trigger modal -->
                <button type="button" class="btn btn-primary btn-lg show-modal" data-toggle="modal" data-target="#myModal">
                  view modal
                </button>

                <!-- Modal -->
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                            <div class="modal-body">
                                <div class="icon"> ! </div>
                                <h3 class="title">Warning!</h3>
                                <p class="description">Lorem Ipsum dolor sit amet</p>
                                <button class="subscribe">Lorem Ipsum</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
                
CSS样式
.modal-box{ font-family: 'Roboto', sans-serif; }
.modal-box .show-modal{
    color: #fff;
    background-color: #555;
    font-size: 18px;
    font-weight: 600;
    text-transform: capitalize;
    padding: 10px 15px;
    margin: 80px auto 0;
    border: none;
    outline: none;
    box-shadow: -5px 5px 1px rgba(0,0,0,0.2);
    display: block;
}
.modal-box .show-modal:hover{
    color: #fff;
    text-decoration: none;
    border: none;
    outline: none;
}
.modal-backdrop.in{ opacity: 0; }
.modal-box .modal{ top: 70px !important; }
.modal-box .modal-dialog{
    width: 400px;
    margin: 30px auto 10px;
}
.modal-box .modal-dialog .modal-content{
    text-align: center;
    border: 3px solid #FFB300;
    border-radius: 15px;
    box-shadow: -12px 12px 1px rgba(0, 0,0,0.2);
    position: relative;
    z-index: 1;
}
.modal-box .modal-dialog .modal-content:before,
.modal-box .modal-dialog .modal-content:after{
    content: "";
    background: linear-gradient(-32deg, #FFB300 49%,#FFC700 50%);
    width: 100%;
    height: 70%;
    border-radius: 12px 12px 0 0;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}
.modal-box .modal-dialog .modal-content:after{
    background: #FFB300;
    width: 25px;
    height: 25px;
    border-radius: 0;
    transform: translateX(-50%) rotate(45deg);
    left: 50%;
    bottom: 100px;
    top: auto;
}
.modal-box .modal-dialog .modal-content .close{
    color: #4D4D4D;
    background-color: #fff;
    font-size: 32px;
    line-height: 30px;
    height: 35px;
    width: 35px;
    border: 3px solid #FFB300;
    border-radius: 50%;
    box-shadow: -5px 5px 1px rgba(0,0,0,0.1);
    opacity: 1;
    position: absolute;
    left: auto;
    right: -10px;
    top: -10px;
    z-index: 1;
    transition: all 0.3s;
}
.modal-box .modal-dialog .modal-content .close:hover{
    color: #fff;
    background-color: #4D4D4D;
    border: 3px solid #262628;
}
.modal-box .modal-dialog .modal-content .modal-body{ padding: 20px 20px 30px !important; }
.modal-box .modal-dialog .modal-content .modal-body .icon{
    color: #3E3E40;
    background: #fff;
    font-size: 80px;
    font-weight: 600;
    text-align: center;
    line-height: 140px;
    height: 110px;
    width: 110px;
    margin: 0 auto 20px;
    -webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.modal-box .modal-dialog .modal-content .modal-body .title{
    color: #3B393F;
    font-family: 'Archivo Black', sans-serif;
    font-size: 50px;
    text-transform: capitalize;
    margin: 0 0 5px 0;
}
.modal-box .modal-dialog .modal-content .modal-body .description{
    color: #3B393F;
    font-size: 16px;
    margin: 0 0 60px;
}
.modal-box .modal-dialog .modal-content .modal-body .subscribe{
    color: #fff;
    background: #3E3E40;
    font-size: 18px;
    padding: 8px 40px;
    font-weight: 500;
    text-transform: uppercase;
    margin: 0 auto;
    border: 3px solid #262628;
    box-shadow: -5px 5px 1px rgba(0,0,0,0.3);
    border-radius: 8px;
    display: block;
    transition: all 0.3s;
}
.modal-box .modal-dialog .modal-content .modal-body .subscribe:hover{
    color: #3B393F;
    background: #FFC700;
    border: 3px solid #FFB300;
}
@media only screen and (max-width: 576px){
    .modal-dialog{ width: 96% !important; }
}