HTML
<!DOCTYPE html>
<html lang="zh-CN">
<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>移动端网站首页</title>
<link rel="stylesheet" href="index.css" />
<script src="iconfont.js"></script>
</head>
<div>
<!--菜单栏-->
<div class="home-a">
<div class="header-a">
<li>
<a href="">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-didiandingwei"></use>
</svg> </a>地址
</li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-mianbao"></use>
</svg>
<a href="">登录用户</a>
</div>
<div class="search">
<a href="">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-sousuo"></use>
</svg>
<form action="">
<input type="search" name="search" value="荞麦面包" />
</form>
</a>
</div>
</div>
<div class="main">
<!--导航-->
<div class="navs">
<a href="" class="icon-a">
<img src="nav/jingxuanshipin.png" alt="" class="icon-b" />
<div class="txt">精选</div>
</a>
<a href="" class="icon-a">
<img src="nav/mianbao.png" alt="" class="icon-b" />
<div class="txt">面包</div>
</a>
<a href="" class="icon-a">
<img src="nav/tianpin.png" alt="" class="icon-b" />
<div class="txt">甜品</div>
</a>
<a href="" class="icon-a">
<img src="nav/guozhi.png" alt="" class="icon-b" />
<div class="txt">果汁</div>
</a>
<a href="" class="icon-a">
<img src="nav/wuliu.png" alt="" class="icon-b" />
<div class="txt">物流</div>
</a>
<a href="" class="icon-a">
<img src="nav/lipinka.png" alt="" class="icon-b" />
<div class="txt">礼品卡</div>
</a>
</div>
</div>
<!--轮播图-->
<div class="picture">
<div class="imglist">
<a href="" class="active"><img src="banner/mianbao.jpg" alt="" /></a>
<a href=""><img src="banner/mianbao.jpg" alt="" /></a>
<a href=""><img src="banner/mianbao.jpg" alt="" /></a>
<div class="button">
<span class="item active"></span>
<span class="item"></span>
<span class="item"></span>
</div>
</div>
<!--产品区-->
<div class="list-container">
<div class="title-ctnr">
<h5>甜品</h5>
<small>推荐</small>
</div>
<ul class="block-ctnr">
<li>
<div class="cover-wrap">
<img src="product/cake.PNG" alt="">
</div>
<div class="cover-cont">
<div class="mov-detail">巧克力甜品</div>
<div class="mov-info">
<div>
<i class="iconfont"></i>
<span>产品价格</span>
</div>
<li>
<div class="cover-wrap">
<img src="product/cake.PNG" alt="">
</div>
<div class="cover-cont">
<div class="mov-detail">巧克力甜品</div>
<div class="mov-info">
<div>
<i class="iconfont"></i>
<span>产品价格</span>
</div>
<li>
<div class="cover-wrap">
<img src="product/cake.PNG" alt="">
</div>
<div class="cover-cont">
<div class="mov-detail">巧克力甜品</div>
<div class="mov-info">
<div>
<i class="iconfont"></i>
<span>产品价格</span>
</div>
<li>
<div class="cover-wrap">
<img src="product/cake.PNG" alt="">
</div>
<div class="cover-cont">
<div class="mov-detail">巧克力甜品</div>
<div class="mov-info">
<div>
<i class="iconfont"></i>
<span>产品价格</span>
</div>
<li>
<div class="cover-wrap">
<img src="product/cake.PNG" alt="">
</div>
<div class="cover-cont">
<div class="mov-detail">巧克力甜品</div>
<div class="mov-info">
<div>
<i class="iconfont"></i>
<span>产品价格</span>
</div>
<li>
<div class="cover-wrap">
<img src="product/cake.PNG" alt="">
</div>
<div class="cover-cont">
<div class="mov-detail">巧克力甜品</div>
<div class="mov-info">
<div>
<i class="iconfont"></i>
<span>产品价格</span>
</div>
</div>
</div>
</li>
</ul>
</div>
<!-- footer-->
<div class="footer">
<li>
<a href="">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-shouyeshouye"></use>
</svg> </a>首页
</li>
<li>
<a href="">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-chanpin"></use>
</svg> </a>产品
</li>
<li>
<a href="">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-gouwuche"></use>
</svg> </a>购物车
</li>
<li>
<a href="">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-wode"></use>
</svg> </a>我的
</li>
</div>
</div>
</body>
</html>
CSS
@import url(shangpin/iconfont.css);
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
color: #666;
}
li {
list-style: none;
}
@media screen and (min-width: 480px) {
:root {
font-size: 12px;
}
}
@media screen and (min-width: 640px) {
:root {
font-size: 14px;
}
}
@media screen and (min-width: 720px) {
:root {
font-size: 16px;
}
}
@media screen and (min-width: 1080px) {
:root {
font-size: 18px;
}
}
/* 菜单栏 */
.home-a .header-a {
background-color: rgb(236, 189, 189);
display: grid;
grid-template-columns: 5rem 1fr 5rem;
place-items: left;
color: #fff;
}
.home-a .header-a li {
font-size: 15px;
color: blue;
}
.home-a .header-a .icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
font-size: 30px;
}
.home-a .search .icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
font-size: 20px;
}
.home-a .search form input {
min-height: 30px;
min-width: 30px;
outline: none;
border: none;
color: gray;
background-color: black;
}
/* */
/* 导航 */
.main .navs {
display: flex;
padding: 0.6rem 0.5rem;
place-content: space-evenly;
place-items: center;
flex-direction: row;
align-items: center;
}
.main .navs .icon-a {
display: flex;
flex-direction: column;
place-items: center;
font-size: 14px;
color: #666;
}
.main .nvas .icon-a .icon-b {
width: 4rem;
height: 4rem;
}
.main .navs img {
height: 40px;
width: 40px;
}
/* 轮播图 */
.picture {
width: 100vw;
height: 60px;
position: relative;
}
.picture .imglist {
width: 100%;
height: 200px;
}
.picture .imglist img {
width: 100%;
height: 300px;
}
.picture .imglist a {
display: none;
}
.picture .imglist a.active {
display: block;
}
.picture .button {
width: 6rem;
height: 3rem;
position: absolute;
top: 10rem;
right: 0em;
display: flex;
justify-content: center;
}
.picture .button .item {
height: 1.1rem;
width: 1.1rem;
border-radius: 50%;
background-color: #ccc;
margin: 0.6rem;
}
.picture .button .item:hover {
cursor: pointer;
}
.picture .button .item.active {
background-color: #e90e9c;
}
/* 产品区 */
.list-container {
margin: 2rem 0;
display: grid;
grid-template-rows: 3rem 1fr;
background-color: #fff;
}
.list-container .title-ctnr {
display: flex;
padding: 4.5rem;
place-content: space-between;
place-items: center;
}
.list-container .title-ctnr span {
color: grey;
}
.list-container .title-ctnr h5 {
font-size: 1rem;
}
.list-container .block-ctnr {
width: 100%;
padding: 2.5rem;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 1rem;
}
.list-container .block-ctnr li {
height: 15rem;
}
.list-container .block-ctnr li img {
width: 100%;
height: 10rem;
}
.cover-cont .mov-detail {
font-size: 1.4rem;
}
.cover-cont .mov-info {
margin-top: 1rem;
display: flex;
place-content: space-between;
align-items: baseline;
color: grey;
}
/* footer */
.footer {
display: flex;
padding: 0;
place-content: space-evenly;
place-items: center;
flex-direction: row;
align-items: center;
}
.footer li {
font-size: 20px;
color: black;
}
.footer .icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
font-size: 45px;
}
效果图