自选一个APP的首页,使用HTML5+CSS进行模拟布局
时间: 2024-02-06 11:02:29 浏览: 106
好的,我选择模拟淘宝APP的首页布局,以下是HTML5和CSS的代码:
HTML5代码:
```
<!DOCTYPE html>
<html>
<head>
<title>淘宝APP首页</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<div class="header-left">
<img src="https://img.alicdn.com/tps/TB1GkV1SXXXXXc3XVXXXXXXXXXX-102-44.png" alt="淘宝图标">
<span>淘宝</span>
</div>
<div class="header-right">
<input type="text" placeholder="搜索宝贝/店铺/分类">
<img src="https://img.alicdn.com/tps/i1/TB1uKlLSXXXXXa4XXXXhSjJFXXX.png" alt="搜索图标">
</div>
</header>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">我的淘宝</a></li>
<li><a href="#">购物车</a></li>
<li><a href="#">消息</a></li>
<li><a href="#">更多</a></li>
</ul>
</nav>
<main>
<div class="banner">
<img src="https://gw.alicdn.com/imgextra/i4/2510800862/TB2w4G2sFXXXXXdXXXXXXXXXXXX_!!2510800862.jpg" alt="banner图">
</div>
<div class="recommend">
<h2>为你推荐</h2>
<ul>
<li>
<a href="#">
<img src="https://gw.alicdn.com/bao/uploaded/i1/2206776402660/O1CN01FZ7k1j1zCQc8tO2aA_!!2206776402660.jpg_290x290q90.jpg_.webp" alt="宝贝1">
<p>宝贝1标题</p>
<span>¥50</span>
</a>
</li>
<li>
<a href="#">
<img src="https://gw.alicdn.com/bao/uploaded/i3/2206776402660/O1CN01UwL6VU1zCQdZmQZv0_!!2206776402660.jpg_290x290q90.jpg_.webp" alt="宝贝2">
<p>宝贝2标题</p>
<span>¥100</span>
</a>
</li>
<li>
<a href="#">
<img src="https://gw.alicdn.com/bao/uploaded/i1/2206776402660/O1CN01ZJ3dZj1zCQc8JgQ1i_!!2206776402660.jpg_290x290q90.jpg_.webp" alt="宝贝3">
<p>宝贝3标题</p>
<span>¥80</span>
</a>
</li>
<li>
<a href="#">
<img src="https://gw.alicdn.com/bao/uploaded/i1/2206776402660/O1CN01FZ7k1j1zCQc8tO2aA_!!2206776402660.jpg_290x290q90.jpg_.webp" alt="宝贝4">
<p>宝贝4标题</p>
<span>¥60</span>
</a>
</li>
</ul>
</div>
</main>
<footer>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">我的淘宝</a></li>
<li><a href="#">购物车</a></li>
<li><a href="#">消息</a></li>
<li><a href="#">更多</a></li>
</ul>
</footer>
</body>
</html>
```
CSS代码:
```
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
header {
background-color: #FF5000;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
}
.header-left img {
width: 20px;
height: 20px;
}
.header-left span {
font-size: 18px;
font-weight: bold;
margin-left: 5px;
}
.header-right input[type="text"] {
width: 200px;
height: 26px;
border-radius: 13px;
border: none;
padding: 0 10px;
}
.header-right img {
width: 20px;
height: 20px;
margin-left: 10px;
}
nav {
background-color: #fff;
display: flex;
justify-content: space-around;
align-items: center;
height: 50px;
box-shadow: 0 2px 2px rgba(0,0,0,0.2);
}
nav ul {
list-style: none;
display: flex;
}
nav li {
margin: 0 10px;
}
nav a {
color: #333;
text-decoration: none;
font-size: 16px;
}
nav a:hover {
color: #FF5000;
}
main {
padding: 10px 20px;
}
.banner img {
width: 100%;
}
.recommend h2 {
font-size: 16px;
font-weight: bold;
margin-bottom: 10px;
}
.recommend ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
}
.recommend li {
width: 50%;
margin-bottom: 20px;
}
.recommend a {
display: block;
text-decoration: none;
color: #333;
}
.recommend img {
width: 100%;
height: auto;
}
.recommend p {
margin-top: 5px;
font-size: 14px;
}
.recommend span {
font-size: 16px;
color: #FF5000;
font-weight: bold;
margin-top: 5px;
display: block;
}
footer {
background-color: #fff;
display: flex;
justify-content: space-around;
align-items: center;
height: 50px;
box-shadow: 0 -2px 2px rgba(0,0,0,0.2);
position: fixed;
bottom: 0;
left: 0;
right: 0;
}
footer ul {
list-style: none;
display: flex;
}
footer li {
margin: 0 10px;
}
footer a {
color: #333;
text-decoration: none;
font-size: 16px;
}
footer a:hover {
color: #FF5000;
}
```
效果展示:
![淘宝APP首页](https://i.loli.net/2021/09/11/6FZzW4euGg2M1pS.png)
阅读全文