grid布局学习
千图网首页模仿
目录设置
index_banner.css源码
@import url(../public/public_reset.css);
.banner-image {
min-width: 1000px;
margin-bottom: 30px;
background-color: greenyellow;
}
.banner-image img {
width: 100%;
}
index_banner.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="index_banner.css">
<title>banner图</title>
</head>
<body>
<div class="banner-image">
<img src="../../static/images/banner.png" alt="">
</div>
</body>
</html>
public_footer.css 源码
@import url(../public_reset.css);
footer {
padding-top: 20px;
padding-bottom: 10px;
min-width: 1000px;
background-color: lavender;
display: grid;
grid-auto-flow: column;
grid-template-columns: repeat(12, 100px);
grid-template-rows: repeat(9, 30px);
justify-content: center;
}
footer > .item {
font-size: smaller;
}
footer > .item1,
footer > .item9,
footer > .item15 {
font-size: inherit;
color: #444;
}
footer > .item7 {
grid-column: span 3;
}
footer > .item7 > a {
padding: 0px 10px;
box-sizing: border-box;
}
footer > .item8 {
grid-row: span 2;
grid-column: span 12;
text-align: center;
line-height: 30px;
}
footer > .item21 {
grid-row: span 7;
grid-column: span 6;
}
footer > .item22 {
grid-row: span 2;
grid-column: span 3;
font-size: large;
align-self: center;
}
footer > .item23 {
grid-row: span 2;
grid-column: span 3;
}
footer > .item23 {
display: flex;
align-items: center;
}
footer > .item23 img {
width: 100%;
}
footer > .item23 a:last-of-type {
padding-left: 20px;
box-sizing: border-box;
}
footer > .item24 {
grid-row: span 3;
grid-column: span 3;
font-size: large;
}
public_footer.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../../../static/font_icon/iconfont.css" />
<link rel="stylesheet" href="public_footer.css" />
<title>公共页脚</title>
</head>
<body>
<footer>
<div class="item item1">常见问题</div>
<div class="item item2">成为签约设计师</div>
<div class="item item3">注册登录</div>
<div class="item item4">帐号/密码</div>
<div class="item item5">发票/售后</div>
<div class="item item6">版权投诉</div>
<div class="item item7 iconfont icon-diamonds">
<a href="">注册声明</a><a href=""> 版权声明</a><a href="">售后服务</a
><a href="">隐私声明</a>
</div>
<div class="item item8">
<p>为了防范电信网络诈骗,如网民接到962110电话,请立即接听</p>
<p>
Copyright ©2013-现在 千图网 沪ICP备10011451号-6 ICP证书: 沪B2-20180057
上海工商 沪公网安备 31011502008675号
</p>
</div>
<div class="item item9">关于千图网</div>
<div class="item item10">关于我们</div>
<div class="item item11">加入我们</div>
<div class="item item12">心系千图</div>
<div class="item item13">Q群联盟</div>
<div class="item item14"></div>
<div class="item item15">产品服务</div>
<div class="item item16">官方博客</div>
<div class="item item17">帮助中心</div>
<div class="item item18"></div>
<div class="item item19"></div>
<div class="item item20"></div>
<div class="item item21"></div>
<div class="item item22">客服咨询</div>
<div class="item item23">
<a href=""><img src="../../../static/images/chat.png" alt="" /></a>
<a href="" alt="">常见问题 >></a>
</div>
<div class="item item24 iconfont icon-shouye">
feedback@58pic.com
</div>
</footer>
</body>
</html>
- public_header.css 源码
@import url(../public_reset.css);
.header-border-bottom {
border-bottom: 2px solid #ebebeb;
}
.header-nav {
width: 1200px;
margin: 0 auto;
min-width: 1000px;
height: 50px;
display: flex;
align-items: center;
justify-content: end;
}
.header-nav > div:first-of-type {
width: 100px;
margin-right: auto;
}
.header-nav > div:last-of-type {
width: 100px;
height: 25px;
line-height: 25px;
text-align: center;
text-decoration: none;
border: 2px solid forestgreen;
border-radius: 10px;
}
.header-nav > .logo img {
width: 100%;
}
.header-nav > div {
width: 70px;
padding: 0 8px;
}
.header > a {
display: flex;
flex-flow: column nowrap;
align-items: center;
}
.header > a:hover {
color: darkgreen;
font-weight: 500;
}
.header-nav > div:nth-of-type(2) {
width: 500px;
margin-right: auto;
}
.header-nav input {
width: 300px;
height: 30px;
border: 1px solid #ebebeb;
}
.header-search {
display: flex;
align-items: center;
}
.header-search span {
width: 60px;
height: 30px;
box-sizing: border-box;
line-height: 30px;
text-align: center;
border-radius: 10px 0px 0px 10px;
border: 1px solid #ebebeb;
}
.header-search img {
width: 100%;
height: 100%;
}
.header-search label {
width: 60px;
height: 30px;
border-radius: 0px 10px 10px 0px;
}
- public_header.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../../../static/font_icon/iconfont.css" />
<link rel="stylesheet" href="public_header.css" />
<title>公共页眉</title>
</head>
<body>
<div class="header-border-bottom">
<div class="header-nav">
<div class="header logo">
<a href="">
<img src="../../../static/images/logo.png" alt="千图网"
/></a>
</div>
<div class="header">
<div class="header-search">
<span><a href="">全部 ></a></span>
<input type="search" name="search" id="search" />
<label for="search"
><img src="../../../static/images/search.png" alt=""
/></label>
</div>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-gengduo"></span> <span>更多</span></a
>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-icon-"></span> <span>创作中心</span></a
>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-diamonds"></span> <span>个人中心</span></a
>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-shenqingchengweiVIP"></span>
<span>企业中心</span></a
>
</div>
<div class="header">
<span
><a href="">登录</a > | <a href="" alt=""
>注册</a
></span
>
</div>
</div>
</div>
</body>
</html>
- public_headline.css 源码
@import url(../public_reset.css);
.headline-title {
width: 1200px;
margin: 0 auto;
}
.headline-title a {
padding: 0 10px;
}
.headline-title a:hover {
color: forestgreen;
}
.headline-title a:first-of-type {
font-size: x-large;
}
.headline-title a:last-of-type {
padding-left: 60px;
}
- public_headline.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../../../static/font_icon/iconfont.css" />
<link rel="stylesheet" href="public_headline.css" />
<title>大标题</title>
</head>
<body>
<div class="headline-title">
<a href="">创意海报</a>
<a href="">千图精选</a>
<a href="">节日海报</a>
<a href="">招聘海报</a>
<a href="">促销海报</a>
<a href="">公益海报</a>
<a href="">查看更多 →</a>
</div>
</body>
</html>
- public_image_list.css 源码
@import url(../public_reset.css);
.image-list {
width: 1200px;
min-width: 1000px;
display: grid;
grid-template-columns: repeat(4, 290px);
grid-template-rows: repeat(2, 430px);
justify-content: space-between;
/* place-content: center; */
margin: 30px auto;
}
.image-list img {
width: 100%;
}
.image-list a {
padding: 10px;
}
.image-list-p {
padding-top: 10px;
font-size: small;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.image-list-p strong {
font-weight: normal;
border-radius: 4px;
color: green;
border: 1px solid green;
}
- public_image_list.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../../../static/font_icon/iconfont.css" />
<link rel="stylesheet" href="../public_image_list/public_image_list.css" />
<title>图片列表</title>
</head>
<body>
<div class="image-list">
<a href=""
><img src="../../../static/images/plate1.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate2.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate3.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate4.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate5.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate6.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate7.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../../../static/images/plate8.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
</div>
</body>
</html>
- public_nav.css 源码
@import url(../public_reset.css);
nav {
width: 800px;
margin: 0 auto;
min-width: 1000px;
height: 30px;
font-size: inherit;
color: #555;
display: flex;
align-items: center;
justify-content: space-evenly;
}
nav div {
width: 80px;
text-align: center;
}
public_nav.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../../../static/font_icon/iconfont.css" />
<link rel="stylesheet" href="public_nav.css" />
<title>导航</title>
</head>
<body>
<nav>
<div><a href="">发现</a></div>
<div><a href="">平面广告</a></div>
<div><a href="">元素|插画</a></div>
<div><a href="">背景|摄影</a></div>
<div><a href="">电商设计</a></div>
<div><a href="">PPT文档</a></div>
<div><a href="">视频|配乐</a></div>
<div><a href="">字库|艺术字</a></div>
<div><a href="">装饰|模型</a></div>
<div><a href="">UI|新媒体</a></div>
</nav>
</body>
</html>
public_reset.css 源码
/* 初始化设置,内外边距为0 */
*{
margin: 0;
padding: 0;
}
a {
/* 去除默认下划线 */
text-decoration: none;
color: #666;
}
body {
/* 设置字体、字号、颜色、背景颜色样式 */
font-family: "Helvetica Neue", Helvetica, "PingFang SC", Tahoma, Arial,
sans-serif;
font-size: 13px;
color: #555;
background-color: #fff;
}
li {
/* 去除默认小点样式 */
list-style: none;
}
index.css 源码
@import url(../components/public/public_reset.css);
/* 页头样式 */
@import url(../components/public/public_header/public_header.css);
/* 导航样式 */
@import url(../components/public/public_nav/public_nav.css);
/* bnaner图样式 */
@import url(../components/index/index_banner.css);
/* 图片列表标题样式 */
@import url(../components/public/public_headline/public_headline.css);
/* 图片列表样式 */
@import url(../components/public/public_image_list/public_image_list.css);
/* 页脚样式 */
@import url(../components/public/public_footer/public_footer.css);
body {
width: 100vw;
margin: 0 auto;
}
index.html 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../static/font_icon/iconfont.css" />
<link rel="stylesheet" href="index.css" />
<title>千图网模仿网页</title>
</head>
<body>
<!-- 页头 -->
<div class="header-border-bottom">
<div class="header-nav">
<div class="header logo">
<a href=""> <img src="../static/images/logo.png" alt="千图网" /></a>
</div>
<div class="header">
<div class="header-search">
<span><a href="">全部 ></a></span>
<input type="search" name="search" id="search" />
<label for="search"
><img src="../static/images/search.png" alt=""
/></label>
</div>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-gengduo"></span> <span>更多</span></a
>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-icon-"></span> <span>创作中心</span></a
>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-diamonds"></span>
<span>个人中心</span></a
>
</div>
<div class="header">
<a href=""
><span class="iconfont icon-shenqingchengweiVIP"></span>
<span>企业中心</span></a
>
</div>
<div class="header">
<span
><a href="">登录</a
> | <a href="" alt=""
>注册</a
></span
>
</div>
</div>
</div>
<!-- 导航 -->
<nav>
<div><a href="">发现</a></div>
<div><a href="">平面广告</a></div>
<div><a href="">元素|插画</a></div>
<div><a href="">背景|摄影</a></div>
<div><a href="">电商设计</a></div>
<div><a href="">PPT文档</a></div>
<div><a href="">视频|配乐</a></div>
<div><a href="">字库|艺术字</a></div>
<div><a href="">装饰|模型</a></div>
<div><a href="">UI|新媒体</a></div>
</nav>
<!-- 轮播图 -->
<div class="banner-image">
<img src="../static/images/banner.png" alt="" />
</div>
<!-- 图片列表 -->
<!-- 列表 1 -->
<!-- 列表 1 标题-->
<div class="headline-title">
<a href="">创意海报</a>
<a href="">千图精选</a>
<a href="">节日海报</a>
<a href="">招聘海报</a>
<a href="">促销海报</a>
<a href="">公益海报</a>
<a href="">查看更多 →</a>
</div>
<!-- 列表 1 图片-->
<div class="image-list">
<a href=""
><img src="../static/images/plate1.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate2.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate3.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate4.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate5.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate6.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate7.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/plate8.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
</div>
<!-- 列表 2 标题-->
<div class="headline-title">
<a href="">展板展架</a>
<a href="">千图精选</a>
<a href="">卡通手绘</a>
<a href="">纹理边框</a>
<a href="">图标元素</a>
<a href="">广告背景</a>
<a href="">查看更多 →</a>
</div>
<!-- 列表 2 图片-->
<div class="image-list">
<a href=""
><img src="../static/images/poster1.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster2.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster3.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster4.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster5.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster6.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster7.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
<a href=""
><img src="../static/images/poster8.png" alt="" />
<p class="image-list-p">
<strong>原创</strong>素材学校复课防疫科普小知识系列海报素材学校
</p></a
>
</div>
<!-- 页脚 -->
<footer>
<div class="item item1">常见问题</div>
<div class="item item2">成为签约设计师</div>
<div class="item item3">注册登录</div>
<div class="item item4">帐号/密码</div>
<div class="item item5">发票/售后</div>
<div class="item item6">版权投诉</div>
<div class="item item7 iconfont icon-diamonds">
<a href="">注册声明</a><a href=""> 版权声明</a><a href="">售后服务</a
><a href="">隐私声明</a>
</div>
<div class="item item8">
<p>为了防范电信网络诈骗,如网民接到962110电话,请立即接听</p>
<p>
Copyright ©2013-现在 千图网 沪ICP备10011451号-6 ICP证书: 沪B2-20180057
上海工商 沪公网安备 31011502008675号
</p>
</div>
<div class="item item9">关于千图网</div>
<div class="item item10">关于我们</div>
<div class="item item11">加入我们</div>
<div class="item item12">心系千图</div>
<div class="item item13">Q群联盟</div>
<div class="item item14"></div>
<div class="item item15">产品服务</div>
<div class="item item16">官方博客</div>
<div class="item item17">帮助中心</div>
<div class="item item18"></div>
<div class="item item19"></div>
<div class="item item20"></div>
<div class="item item21"></div>
<div class="item item22">客服咨询</div>
<div class="item item23">
<a href=""><img src="../static/images/chat.png" alt="" /></a>
<a href="" alt="">常见问题 >></a>
</div>
<div class="item item24 iconfont icon-shouye">
feedback@58pic.com
</div>
</footer>
</body>
</html>
- 显示效果
学习总结:
模仿千图网前端页面有8成,感觉有很多源码有冗余的地方,需要改进的地方还有很多,grid布局感觉这个非常好,相信以后用到的地方还有很多,总之,这个页面完成的有点吃力,算是入了个门槛,给自己加油ヾ(◍°∇°◍)ノ゙