代碼
提交代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- 在這里用link標簽引入中文漸變色 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chinese-gradient">
<style>
/* 清除默認樣式 */
* { padding: 0; margin: 0; }
/* 全屏顯示 */
html, body, ul { height: 100% }
/* 父元素 */
ul {
/* 清除默認樣式 */
list-style: none;
/* 顯示為網(wǎng)格布局 */
display: grid;
/* 均分成三行三列 */
grid: repeat(3, 1fr) / repeat(3, 1fr);
/* 給個合適的間距 */
gap: 20px;
/* 調(diào)用動畫 */
animation: clear-gap 5s ease-out infinite alternate
}
/* 子元素 */
li {
/* 兩像素的邊框 */
border: 2px solid black
}
/* 定義動畫 */
@keyframes clear-gap { to { gap: 0 } }
/* 第一個子元素 */
li:first-child {
border-right: none;
border-bottom: none;
}
/* 第二個子元素 */
li:nth-child(2) {
border-bottom: none;
}
/* 第三個子元素 */
li:nth-child(3) {
border-left: none;
border-bottom: none;
}
/* 第四個子元素 */
li:nth-child(4) {
border-right: none;
}
/* 第六個子元素 */
li:nth-child(6) {
border-left: none;
}
/* 第七個子元素 */
li:nth-child(7) {
border-top: none;
border-right: none;
}
/* 第八個子元素 */
li:nth-child(8) {
border-top: none;
}
/* 第九個子元素 */
li:last-child {
border-top: none;
border-left: none;
}
</style>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
運行結(jié)果