html messagebox
时间: 2023-11-21 19:58:51 浏览: 30
以下是一个简单的HTML消息框的例子:
```html
<!DOCTYPE html>
<html>
<head>
<title>HTML Message Box</title>
<style>
#messageBoxContainer {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
z-index: 9999;
}
#messageBoxContent {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
text-align: center;
}
#messageBoxContent h2 {
margin-top: 0;
}
#closeMessageBox {
margin-top: 10px;
padding: 5px 10px;
background-color: #f00;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<button id="showMessageBox">显示弹窗</button>
<div id="messageBoxContainer">
<div id="messageBoxContent">
<h2>这是一个弹窗</h2>
<p>欢迎使用HTML消息框示例!</p>
<button id="closeMessageBox">关闭</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("#showMessageBox").click(function() {
$("#messageBoxContainer").fadeIn();
});
$("#closeMessageBox").click(function() {
$("#messageBoxContainer").fadeOut();
});
});
</script>
</body>
</html>
```
该示例包含一个按钮,单击该按钮将显示一个消息框。消息框包含一个标题,一些文本和一个关闭按钮。单击关闭按钮将隐藏消息框。