
批改狀態(tài):合格
老師批語:
源碼:
<!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>實(shí)例演示模態(tài)框</title>
<style>
@import 'static/media.css';
@import 'static/modal.css';
</style>
</head>
<body>
<header>
<h1>似水流年の博客</h1>
<button onclick="showModal()">登陸</button>
</header>
<nav>
<a href="">首頁</a>
<a href="">日記</a>
<a href="">資訊</a>
<a href="">資料</a>
</nav>
<section>
<article>
<h2>文章標(biāo)題</h2>
</article>
<aside>
<dt>分類</dt>
<dd>日記</dd>
<dd>資訊</dd>
<dd>資料</dd>
</aside>
</section>
<footer>
<div class="contact">
<a class="contact" href="">關(guān)于我們</a><a href="">版權(quán)聲明</a><a href="">聯(lián)系我們</a>
</div>
<div class="line"></div>
<div class="copyright">
<p>copyright ? 2022 似水流年</p>
</div>
</footer>
<!-- 模態(tài)框 -->
<div class="modal">
<!-- 1. 半透明的遮罩 -->
<div class="modal-bg" onclick="closeModal()"></div>
<!-- 2. 彈層表單 -->
<form action="" class="modal-form">
<fieldset style="display: grid; gap: 1em">
<legend>用戶登錄</legend>
<input type="email" name="email" placeholder="user@email.com" />
<input type="password" name="password" placeholder="不少于6位" />
<button>登錄</button>
</fieldset>
</form>
</div>
<script src="static/modal.js" ></script>
</body>
</html>
media.css樣式:
<style>
*{margin: 0;padding: 0;box-sizing: border-box;}
/* 媒體尺寸小于767的顯示樣式 */
@media (max-width:767px) {
.header{
background-color: #ccc;
}
/* 未寫完 */
}
/* 媒體尺寸大于768的顯示樣式 */
@media (min-width:768px){
header{
background-color: indigo;
padding: 0.5em 1em;
display: flex;
}
header h1{
color: #fff;
font-weight:lighter;
letter-spacing: 2px;
/* 字間距 */
text-shadow: 1px 1px 1px #fff;
/* 字體陰影 向左距離,向下的距離,模糊的距離,顏色 */
}
header button{
color: #000;
margin-left: auto;
background-color: bisque;
font-size: 15px;
width: 4em;
height: 2em;
border: none;
border-radius: 0.3em;
cursor: pointer;
}
header button:hover{
color: #fff;
margin-left: auto;
background-color: bisque;
font-size: 15px;
width: 4em;
height: 2em;
border: none;
border-radius: 0.3em;
cursor: pointer;
box-shadow: 0 0 0.2em #fff;
}
nav{
background-color: rgb(53, 6, 53);
height: 2.5em;
line-height: 2.5em;
font-size: 2em;
}
nav>a:nth-of-type(-n+3){
border-right: 1px solid #fff;
}
nav a{
color: #fff;
padding: 0 0.5em 0.5em ;
text-decoration: none;
}
nav a:hover{
color: #fff;
padding: 0 0.5em 0.5em ;
background-color: darkorchid;
}
section{
display: flex;
}
article{
border: 1px solid #ccc;
margin: 1em 1em;
border-radius: 0.5em;
padding: 1em ;
width: 70%;
}
article>h2{
color: rgb(4, 71, 216);
border-bottom: 1px dashed #ccc;
margin-bottom: 5em;
}
aside{
margin:1em 1em 1em 0.5em;
width: 20%;
border: 1px dashed #ccc;
border-radius: 0.5em;
}
aside>dt{
font-weight: bold;
border-bottom: 1px dashed #ccc;
}
aside>dd{
padding: 0.1em;
}
footer{
background-color: indigo;
padding: 0.1em 0.2em;
color: #fff;
font-size: 16px;
}
.contact{
margin: 0 auto;
}
.contact a{
color: #fff;
text-decoration: none;
letter-spacing: 0.1em;
padding-left: 0.5em;
}
.line{
margin: 0.5em 0em;
height: 1px;
background-color: rgb(166, 51, 177);
}
.copyright{
margin: 0 auto;
}
}
/* 模塊框表單部分樣式是復(fù)制的老師的 */
/* 模態(tài)框 */
.modal .modal-form fieldset {
height: 15.5em;
background-color: #dd5a57;
border: none;
padding: 2em 3em;
box-shadow: 0 0 5px #888;
}
/* 模態(tài)框表單標(biāo)題 */
.modal .modal-form fieldset legend {
padding: 7px 1.5em;
background-color: rgb(4, 71, 216);
color: white;
}
.modal .modal-form fieldset input {
height: 3em;
padding-left: 1em;
outline: none;
border: 1px solid #ddd;
font-size: 14px;
}
/* :focus: 表單控件,獲取焦點(diǎn)時(shí)的樣式 */
.modal .modal-form fieldset input:focus {
box-shadow: 0 0 8px #888;
border: none;
}
.modal .modal-form fieldset button {
background-color: rgb(4, 71, 216);
color: white;
border: none;
height: 3em;
font-size: 16px;
height: 2.5em;
}
.modal .modal-form fieldset button:hover {
background-color: coral;
cursor: pointer;
}
/* 定位 */
.modal .modal-form {
position: fixed;
top: 10em;
left: 38em;
right: 38em;
}
/* 遮罩 */
.modal .modal-bg {
position: fixed;
/* 坐標(biāo)全部清0,請定位到四個(gè)頂點(diǎn) */
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgb(0, 0, 0, 0.5);
}
.modal {
display: none;
}
</style>
預(yù)覽圖:
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號