webveuje/teaching/lhj/kejian/grid.html
2021-04-29 17:16:40 +08:00

103 lines
2.6 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>Document</title>
<Style>
*{
margin: 0;
padding: 0;
}
.box{
display: grid;
grid-template-columns: 100px 100px 100px;
grid-template-rows: 100px 100px 100px;
grid-row-gap:10px;/*(行间距)*/
grid-column-gap: 10px;/* 列间距*/
}
.item{
border: 1px solid black;
}
.box1{
display: grid;
grid-template-columns: repeat(3,100px);
grid-template-rows: repeat(3,100px)
}
.box2{
display: grid;
width: 800px;
grid-template-columns: repeat(auto-fill,100px);
grid-template-rows: repeat(3,100px)
}
.box3{
display: grid;
width: 800px;
grid-template-columns: 1fr 2fr;
}
</Style>
</head>
<body>
<p>demp1 grid布局基本用法</p>
<div class="box">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9 </div>
</div>
<p>demp2 使用repeat重写</p>
<div class="box1">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9 </div>
</div>
<p>demp3 auto-fill</p>
<div class="box2">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9 </div>
</div>
<p>demp4 fr</p>
<div class="box3">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9 </div>
</div>
</body>
</html>