Bootstrap自定义模态窗口样式

Bootstrap自定义模态窗口样式

这是一款Bootstrap自定义模态窗口样式。高模态窗口通过简单的CSS代码,将原生的bootstrap模态窗口进行美化。
使用方法
在页面中引入下面的文件。

1
2
3
<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结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<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样式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.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; }
}
当前内容只有登录了才能查看,如果您已经注册,请登录
0

发表评论