Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>练习模态框</title>
<link rel="stylesheet" href="作业1.css">
</head>
<body>
<header>
<h2>后台管理系统</h2>
<button>登录</button>
</header>
<!-- 模态框 -->
<div class="modal">
<!-- 半透明的遮罩 -->
<div class="modal-bg"></div>
<!-- 弹窗表单 -->
<form action="" class="my_form">
<fieldset style="display: grid;gap: 1em;">
<legend>用户登录</legend>
<label for="user">账号:</label>
<input type="text" id="user" placeholder="请输入账号">
<label for="pwd">密码:</label>
<input type="password" id="pwd" placeholder="至少8位">
<button>登录</button>
</fieldset>
</form>
</div>
</body>
</html>
css:
/* 初始化 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 头部 */
header {
background-color:chocolate;
padding: 1.5em 1em;
display: flex;
}
/* logo */
header > h2 {
margin-left: auto ;
margin-right: auto;
color:azure;
}
/* 登录按钮 */
header > button {
letter-spacing: 2px;
border: none;
border-radius: 0.5em;
width: 5em;
}
header >button:hover {
cursor: pointer;
background-color:blueviolet;
color: white;
transition: 0.5s;
box-shadow: 0 0 10px white;
}
/* 模态框 */
.modal .my_form fieldset {
height: 18em;
border: none;
padding: 3em 7em;
background-color:gainsboro;
}
/* 模态框表单内容 */
.modal .my_form fieldset input {
height: 25px;
outline: none;
margin-left: 1em;
border: 1px solid white;
}
/* 获取焦点后,阴影发光 */
.modal .my_form fieldset input:focus {
box-shadow: 0 0 10px black;
}
/* 表单登录按钮 */
.modal .my_form fieldset button {
cursor: pointer;
font-size: 15px;
letter-spacing: 3px;
border-radius: 1.5em;
}
/* 登录键鼠标悬停 */
.modal .my_form fieldset button:hover {
background-color:blueviolet;
color: white;
outline: none;
border-radius: 1.5em;
transition: 0.5s;
border: 1px solid ;
box-shadow: 0 0 10px white;
}
/* 定位 */
.modal .my_form {
position: fixed;
top: 15em;
left: 35em;
right:40em;
}
/* 遮罩半透明 */
.modal .modal-bg {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color:rgb(0,0,0,0.5 );
}
效果如下: