按钮样式
.btn {
width:60px;
margin-top: 10px;
background-color: #4CAF50;
border-radius: 5px;
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
float: right;
}
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<html lang="en">
<head>
<meta charset="UTF-8">
<title>弹出遮罩</title>
<style>
/*关闭弹窗*/
.popBox {
display: none;
}
/*打开弹窗*/
.popBox:target {
align-items: center;
display: flex;
justify-content: center;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
/*弹窗内容*/
.popBox .con {
background-color: #fff;
border-radius: 5px;
padding: 0.8rem;
position: relative;
width: 15rem;
font-size: 14px;
}
/*关闭按钮*/
.popBox .close {
display: block;
position: relative;
}
.popBox .close::after {
align-items: center;
color: white;
content: "×";
cursor: pointer;
background-color: rgba(79, 79, 79, 0.9);
border-radius: 50%;
display: flex;
font-size: 1.25rem;
justify-content: center;
position: absolute;
right: -1.5rem;
top: -1.5rem;
height: 1.5rem;
width: 1.5rem;
z-index: 2;
}
/*弹窗遮罩层*/
.popBox::before {
content: "";
cursor: default;
background-color: rgba(173, 173, 173, 0.66);
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.btn {
margin-top: 10px;
background-color: #4CAF50;
border-radius: 5px;
border: none;
color: white;
padding: 5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
float: right;
}
</style>
</head>
<body>
<ul>
<li><a href="#example">弹出遮罩</a></li>
</ul>
<article class="popBox" id="example">
<div class="con">
<a href="#" class="close"></a>
<p>弹出内容文字<br><button class="btn">复制</button></button>
</p>
</div>
</article>
</body>
</html>
bootatrap弹出层插件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap 实例 - 弹出层插件</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h2>创建模态框(Modal)</h2>
<!-- 按钮触发模态框 -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
开始演示模态框
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="margin-top: 150px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
注意
</h4>
</div>
<div class="modal-body">
弹出层文字说明
</div>
</div>
</div>
</div>
</body>
</html>
网友评论