从小白到经过这几天的学习,发现编程是一个很有趣的事,把自己所想的页面,一个一个的敲出来,尽管会遇到很多的问题,很多很久都跳不出的坑,就像这次Grid
实战运用
因为没有老师带着敲,导致自己根本没有头绪,不知道如何去布置,如何真正的将学到的只是运用到实战上面来,后面还是看了同学的源码借鉴了下,才将本次的作业完成。
以下是效果图:
以下是HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>二手交易grid布局</title>
<link rel="stylesheet" href="second-hand.css">
</head>
<body>
<!-- 标头,标题,分类,图片,广告-->
<span>二手交易</span>
<div class="second-hand">
<div class="option">
<a href="">抢好货</a>
<span>0低价,便捷,安全,快速</span>
</div>
<div class="class">
<span>热门分类</span>
<a href="">美女写真</a>
<a href="">日本美女</a>
<a href="">美女图片</a>
<a href="">美女写真</a>
<a href="">美女写真</a>
<a href="">美女写真</a>
</div>
<div class="picture-ads">
<div class="picture">
<div class="a">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="b">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="c">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="d">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="e">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="f">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="g">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
<div class="h">
<a href="">
<img src="1225/static/images/1.jpg" alt="">
</a>
<a href="">美女妹妹美女妹妹美女妹妹美女妹妹</a>
<div class="money">
<span>¥333</span>
<span>美女</span>
</div>
</div>
</div>
<div class="ads">
<a href="" class="q"><img src="1225/static/images/ad/1.png" alt=""></a>
<a href="" class="w"><img src="1225/static/images/ad/2.png" alt=""></a>
<a href="" class="u"><img src="1225/static/images/ad/3.png" alt=""></a>
<a href="" class="r"><img src="1225/static/images/ad/4.png" alt=""></a>
<a href="" class="t"><img src="1225/static/images/ad/ad2.jpg" alt=""></a>
<a href="" class="y"><img src="1225/static/images/ad/image.png" alt=""></a>
</div>
</div>
</div>
</body>
</html>
以下是CSS:
* {
padding: 0;
margin: 0;
/*outline: 1px dashed red;*/
}
a {
text-decoration: none;
color: #555555;
}
body {
display: flex;
flex-flow: column nowrap;
color: #555555;
background-color: #eeffee;
}
body > span {
font-size: 35px;
margin: 20px auto;
border-bottom: 3px solid red;
box-sizing: border-box;
}
.second-hand {
width: 1200px;
margin: auto;
background-color: #ffffff;
}
.second-hand:hover {
box-shadow: 0 0 8px #888;
}
.second-hand > .picture-ads > .picture img {
width: 176px;
height: 120px;
/*display: block;*/
}
/*标题格式*/
.second-hand > .option {
padding: 10px 10px 20px;
border-bottom: 1px solid #555555;
}
.second-hand > .option > a {
font-size: 20px;
color: black;
}
.second-hand > .option > span {
margin-left: 5px;
color: red;
}
.second-hand > .class {
padding: 10px;
}
.second-hand > .class > span {
color: red;
font-size: 25px;
}
.second-hand > .class > a {
margin-left: 5px;
color: black;
}
.second-hand > .class > a:hover {
color: red;
}
.second-hand > .picture-ads{
display: grid;
grid-template-columns: 8fr 4fr;
}
.second-hand > .picture-ads > .picture {
display: grid;
grid-template-columns: repeat(4,4fr);
grid-template-rows: repeat(2,2fr);
/*grid-gap: 10px;*/
}
.second-hand > .picture-ads > .picture > div > .money {
display: flex;
justify-content: space-between;
}
.second-hand > .picture-ads > .picture > div > .money >span:first-of-type{
color: red;
}
.second-hand > .picture-ads > .picture > div > .money >span:last-of-type {
background-color: lawngreen;
border-radius: 5px;
}
/*将元素放进网格中*/
.second-hand > .picture-ads > .picture > div {
margin-top: 10px;
display: grid;
grid-auto-columns: 180px;
grid-template-rows: 130px 2fr 0.6fr;
}
.second-hand > .picture-ads > .ads {
padding: 5px;
box-sizing: border-box;
display: grid;
grid-template-areas:
'q w'
'u r'
't t'
'y y'
;
/*grid-gap: 5px;*/
}
.second-hand > .picture-ads > .ads > .q {
width: 100%;
grid-area: q;
}
.second-hand > .picture-ads > .ads > .w {
width: 100%;
grid-area: w;
}
.second-hand > .picture-ads > .ads > .u{
width: 100%;
grid-area: u;
}
.second-hand > .picture-ads > .ads > .r{
width: 100%;
grid-area: r;
}
.second-hand > .picture-ads > .ads > .t {
width: 100%;
grid-area: t;
}
.second-hand > .picture-ads > .ads > .y {
width: 100%;
grid-area: y;
}
/**/
}
padding: 0;
margin: 0;
/*outline: 1px dashed red;*/
a {
text-decoration: none;
color: #555555;
}
body {
display: flex;
flex-flow: column nowrap;
color: #555555;
background-color: #eeffee;
}
body > span {
font-size: 35px;
margin: 20px auto;
border-bottom: 3px solid red;
box-sizing: border-box;
}
.second-hand {
width: 1200px;
margin: auto;
background-color: #ffffff;
}
.second-hand:hover {
box-shadow: 0 0 8px #888;
}
.second-hand > .picture-ads > .picture img {
width: 176px;
height: 120px;
/display: block;/
}
/标题格式/
.second-hand > .option {
padding: 10px 10px 20px;
border-bottom: 1px solid #555555;
}
.second-hand > .option > a {
font-size: 20px;
color: black;
}
.second-hand > .option > span {
margin-left: 5px;
color: red;
}
.second-hand > .class {
padding: 10px;
}
.second-hand > .class > span {
color: red;
font-size: 25px;
}
.second-hand > .class > a {
margin-left: 5px;
color: black;
}
.second-hand > .class > a:hover {
color: red;
}
.second-hand > .picture-ads{
display: grid;
grid-template-columns: 8fr 4fr;
}
.second-hand > .picture-ads > .picture {
display: grid;
grid-template-columns: repeat(4,4fr);
grid-template-rows: repeat(2,2fr);
/grid-gap: 10px;/
}
.second-hand > .picture-ads > .picture > div > .money {
display: flex;
justify-content: space-between;
}
.second-hand > .picture-ads > .picture > div > .money >span:first-of-type{
color: red;
}
.second-hand > .picture-ads > .picture > div > .money >span:last-of-type {
background-color: lawngreen;
border-radius: 5px;
}
/将元素放进网格中/
.second-hand > .picture-ads > .picture > div {
margin-top: 10px;
display: grid;
grid-auto-columns: 180px;
grid-template-rows: 130px 2fr 0.6fr;
}
.second-hand > .picture-ads > .ads {
padding: 5px;
box-sizing: border-box;
display: grid;
grid-template-areas:
‘q w’
‘u r’
‘t t’
‘y y’
;
/grid-gap: 5px;/
}
.second-hand > .picture-ads > .ads > .q {
width: 100%;
grid-area: q;
}
.second-hand > .picture-ads > .ads > .w {
width: 100%;
grid-area: w;
}
.second-hand > .picture-ads > .ads > .u{
width: 100%;
grid-area: u;
}
.second-hand > .picture-ads > .ads > .r{
width: 100%;
grid-area: r;
}
.second-hand > .picture-ads > .ads > .t {
width: 100%;
grid-area: t;
}
.second-hand > .picture-ads > .ads > .y {
width: 100%;
grid-area: y;
}
/*/ {
padding: 0;
margin: 0;
/outline: 1px dashed red;/
}
a {
text-decoration: none;
color: #555555;
}
body {
display: flex;
flex-flow: column nowrap;
color: #555555;
background-color: #eeffee;
}
body > span {
font-size: 35px;
margin: 20px auto;
border-bottom: 3px solid red;
box-sizing: border-box;
}
.second-hand {
width: 1200px;
margin: auto;
background-color: #ffffff;
}
.second-hand:hover {
box-shadow: 0 0 8px #888;
}
.second-hand > .picture-ads > .picture img {
width: 176px;
height: 120px;
/display: block;/
}
/标题格式/
.second-hand > .option {
padding: 10px 10px 20px;
border-bottom: 1px solid #555555;
}
.second-hand > .option > a {
font-size: 20px;
color: black;
}
.second-hand > .option > span {
margin-left: 5px;
color: red;
}
.second-hand > .class {
padding: 10px;
}
.second-hand > .class > span {
color: red;
font-size: 25px;
}
.second-hand > .class > a {
margin-left: 5px;
color: black;
}
.second-hand > .class > a:hover {
color: red;
}
.second-hand > .picture-ads{
display: grid;
grid-template-columns: 8fr 4fr;
}
.second-hand > .picture-ads > .picture {
display: grid;
grid-template-columns: repeat(4,4fr);
grid-template-rows: repeat(2,2fr);
/grid-gap: 10px;/
}
.second-hand > .picture-ads > .picture > div > .money {
display: flex;
justify-content: space-between;
}
.second-hand > .picture-ads > .picture > div > .money >span:first-of-type{
color: red;
}
.second-hand > .picture-ads > .picture > div > .money >span:last-of-type {
background-color: lawngreen;
border-radius: 5px;
}
/将元素放进网格中/
.second-hand > .picture-ads > .picture > div {
margin-top: 10px;
display: grid;
grid-auto-columns: 180px;
grid-template-rows: 130px 2fr 0.6fr;
}
.second-hand > .picture-ads > .ads {
padding: 5px;
box-sizing: border-box;
display: grid;
grid-template-areas:
‘q w’
‘u r’
‘t t’
‘y y’
;
/grid-gap: 5px;/
}
.second-hand > .picture-ads > .ads > .q {
width: 100%;
grid-area: q;
}
.second-hand > .picture-ads > .ads > .w {
width: 100%;
grid-area: w;
}
.second-hand > .picture-ads > .ads > .u{
width: 100%;
grid-area: u;
}
.second-hand > .picture-ads > .ads > .r{
width: 100%;
grid-area: r;
}
.second-hand > .picture-ads > .ads > .t {
width: 100%;
grid-area: t;
}
.second-hand > .picture-ads > .ads > .y {
width: 100%;
grid-area: y;
}
/**/
基础知识一定要记牢,基础知识一定要记牢,基础知识一定要记牢
一定要多看多练,一定要多看多练,一定要多看多练
相信自己一定能将PHP学好