CSS Grid网格布局
1、教程
2、demo
<!DOCTYPE html>
<html>
<head>
<title>CSS Grid 布局</title>
<meta charset="utf-8">
</head>
<body>
<div>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
</div>
</body>
<style>
* {
margin: 0;
padding: 0;
}
div {
display: grid;
justify-content: center;
align-content: center;
grid-template-columns: repeat(3, 194px);
grid-template-rows: repeat(3, 194px);
grid-row-gap: 2px;
grid-column-gap: 2px;
}
div > p {
text-align: center;
line-height: 194px;
color: #FFFFFF;
font-family: "FangSong";
font-size: 60px;
font-weight: bold;
transition: font-size 1s linear;
}
div > p:hover {
font-size: 120px;
}
div > p:nth-child(1) {
background-color: #1ABC9C;
}
div > p:nth-child(2) {
background-color: #2ECC71;
}
div > p:nth-child(3) {
background-color: #3498DB;
}
div > p:nth-child(4) {
background-color: #9B59B6;
}
div > p:nth-child(5) {
background-color: #16A085;
}
div > p:nth-child(6) {
background-color: #27AE60;
}
div > p:nth-child(7) {
background-color: #2980B9;
}
div > p:nth-child(8) {
background-color: #8E44AD;
}
div > p:nth-child(9) {
background-color: #BDC3C7;
}
</style>
</html>
-----------------------------------------------------------------------------------------------------------
薔薇猛虎皆成個性,陽光雨露俱是天恩!
薔薇猛虎皆成個性,陽光雨露俱是天恩!
浙公网安备 33010602011771号