帮我写美食团购页面设计的html和css代码
时间: 2024-01-30 18:02:06 浏览: 48
好的,以下是一个简单的美食团购页面设计的HTML和CSS代码示例:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>美食团购页面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">团购</a></li>
<li><a href="#">商家</a></li>
<li><a href="#">我的</a></li>
</ul>
</nav>
</header>
<main>
<section id="banner">
<h1>美食团购</h1>
<p>最新最热门的美食团购信息,尽在这里!</p>
</section>
<section id="deal-list">
<div class="deal-item">
<img src="https://via.placeholder.com/150x150" alt="deal image">
<h2>团购1</h2>
<p>描述1</p>
<span class="price">¥100</span>
<span class="discount">5折</span>
<a href="#" class="buy-btn">立即购买</a>
</div>
<div class="deal-item">
<img src="https://via.placeholder.com/150x150" alt="deal image">
<h2>团购2</h2>
<p>描述2</p>
<span class="price">¥200</span>
<span class="discount">6折</span>
<a href="#" class="buy-btn">立即购买</a>
</div>
<div class="deal-item">
<img src="https://via.placeholder.com/150x150" alt="deal image">
<h2>团购3</h2>
<p>描述3</p>
<span class="price">¥300</span>
<span class="discount">7折</span>
<a href="#" class="buy-btn">立即购买</a>
</div>
</section>
</main>
<footer>
<p>版权所有 © 2021 美食团购</p>
</footer>
</body>
</html>
```
CSS代码:
```css
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav li {
margin-right: 20px;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
#banner {
background-image: url("https://via.placeholder.com/1200x400");
background-size: cover;
background-position: center;
height: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
#banner h1 {
font-size: 50px;
margin: 0;
}
#banner p {
font-size: 24px;
margin: 20px 0;
}
#deal-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.deal-item {
width: 30%;
margin-bottom: 20px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
text-align: center;
}
.deal-item img {
width: 100%;
border-radius: 5px;
margin-bottom: 10px;
}
.deal-item h2 {
font-size: 20px;
margin: 0;
}
.deal-item p {
font-size: 14px;
margin: 10px 0;
}
.deal-item .price {
font-size: 24px;
color: #f00;
margin-right: 10px;
}
.deal-item .discount {
font-size: 14px;
color: #999;
}
.buy-btn {
display: inline-block;
padding: 10px 20px;
background-color: #f00;
color: #fff;
text-decoration: none;
border-radius: 5px;
margin-top: 10px;
}
```
你可以根据自己的需求进一步修改代码和样式。
阅读全文