代碼
提交代碼
<!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標(biāo)簽引入中文漸變色 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chinese-gradient">
<style>
/* 清除默認(rèn)樣式 */
* { padding: 0; margin: 0; }
/* 全屏顯示 */
html, body, ul { height: 100% }
/* 父元素 */
ul {
/* 清除默認(rèn)樣式 */
list-style: none
}
/* 子元素 */
li {
/* 絕對(duì)定位 */
position: absolute;
/* 寬高都是33% */
width: 33%;
height: 33%;
/* 紅色漸變 */
background: var(--火紅)
}
/* 第一個(gè)子元素 */
li:first-child {
top: 0;
left: 0;
}
/* 第二個(gè)子元素 */
li:nth-child(2) {
top: 0;
left: 33.33%;
}
/* 第三個(gè)子元素 */
li:nth-child(3) {
top: 0;
left: 66.66%;
}
/* 第四個(gè)子元素 */
li:nth-child(4) {
top: 33.33%;
left: 0;
}
/* 第五個(gè)子元素 */
li:nth-child(5) {
top: 33.33%;
left: 33.33%;
}
/* 第六個(gè)子元素 */
li:nth-child(6) {
top: 33.33%;
left: 66.66%;
}
/* 第七個(gè)子元素 */
li:nth-child(7) {
top: 66.66%;
left: 0;
}
/* 第八個(gè)子元素 */
li:nth-child(8) {
top: 66.66%;
left: 33.33%;
}
/* 第九個(gè)子元素 */
li:last-child {
top: 66.66%;
left: 66.66%;
}
</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>
運(yùn)行結(jié)果