103 lines
2.6 KiB
HTML
103 lines
2.6 KiB
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>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> |