html + css美食网站代码
时间: 2023-07-29 21:09:43 浏览: 419
以下是一个简单的 HTML 和 CSS 实现的美食网站的代码,仅供参考:
HTML 代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食网站</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>美食网站</h1>
</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>
<section class="featured">
<h2>特色菜谱</h2>
<ul>
<li>
<img src="https://picsum.photos/200?random=1" alt="">
<h3>糖醋里脊</h3>
<p>糖醋里脊是一道酸甜可口的传统中式美食,适合各个年龄段的人群。</p>
<a href="#">查看详情</a>
</li>
<li>
<img src="https://picsum.photos/200?random=2" alt="">
<h3>红烧肉</h3>
<p>红烧肉是一道特色传统中式美食,深受广大人民群众的喜爱。</p>
<a href="#">查看详情</a>
</li>
<li>
<img src="https://picsum.photos/200?random=3" alt="">
<h3>麻婆豆腐</h3>
<p>麻婆豆腐是一道川菜代表,口感麻辣,香气四溢。</p>
<a href="#">查看详情</a>
</li>
</ul>
</section>
<section class="recipes">
<h2>热门菜谱</h2>
<ul>
<li>
<img src="https://picsum.photos/200?random=4" alt="">
<h3>清蒸鲈鱼</h3>
</li>
<li>
<img src="https://picsum.photos/200?random=5" alt="">
<h3>宫保鸡丁</h3>
</li>
<li>
<img src="https://picsum.photos/200?random=6" alt="">
<h3>蒜香排骨</h3>
</li>
<li>
<img src="https://picsum.photos/200?random=7" alt="">
<h3>红烧茄子</h3>
</li>
</ul>
</section>
</main>
<footer>
<p>版权所有 © 2021 美食网站</p>
</footer>
</body>
</html>
```
CSS 代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
line-height: 1.5;
}
header {
background-color: #f5f5f5;
padding: 20px;
text-align: center;
}
nav {
background-color: #333;
color: white;
padding: 10px;
}
nav ul {
list-style: none;
display: flex;
justify-content: center;
}
nav ul li {
margin: 0 10px;
}
nav ul li a {
color: white;
text-decoration: none;
}
main {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
section {
margin: 40px 0;
}
section h2 {
font-size: 24px;
margin-bottom: 20px;
}
section ul {
list-style: none;
display: flex;
justify-content: space-between;
}
section li {
width: 30%;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
text-align: center;
transition: all 0.3s ease-in-out;
}
section li:hover {
transform: translateY(-5px);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}
section li img {
width: 100%;
margin-bottom: 10px;
}
section li h3 {
font-size: 18px;
margin-bottom: 10px;
}
section li p {
font-size: 14px;
margin-bottom: 10px;
}
section li a {
display: block;
background-color: #333;
color: white;
padding: 5px;
border-radius: 5px;
text-decoration: none;
}
section li a:hover {
background-color: #555;
}
footer {
background-color: #f5f5f5;
padding: 10px;
text-align: center;
}
```
这个美食网站包含了首页、菜谱和热门菜谱等页面,你可以根据自己的需求进行修改和扩展。