用HTML和css做一个宠物家园的网页
时间: 2024-01-30 07:01:56 浏览: 156
js 前端实现网页计算器
好的,下面是一个简单的宠物家园网页的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>
<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 class="banner">
<h2>欢迎来到宠物家园</h2>
<p>这里是您和您的宠物们的家园</p>
<a href="#">了解更多</a>
</section>
<section class="pets">
<h2>我们的宠物</h2>
<ul>
<li>
<img src="pet1.jpg" alt="宠物1">
<h3>小狗</h3>
<p>价格:$100</p>
<a href="#">购买</a>
</li>
<li>
<img src="pet2.jpg" alt="宠物2">
<h3>小猫</h3>
<p>价格:$80</p>
<a href="#">购买</a>
</li>
<li>
<img src="pet3.jpg" alt="宠物3">
<h3>小鸟</h3>
<p>价格:$50</p>
<a href="#">购买</a>
</li>
</ul>
</section>
</main>
<footer>
<p>© 2021 宠物家园</p>
</footer>
</body>
</html>
```
CSS代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
background-color: #333;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
}
nav ul {
display: flex;
list-style: none;
}
nav ul li {
margin-right: 10px;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
.banner {
background-image: url(banner.jpg);
background-size: cover;
background-position: center;
height: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.banner h2 {
font-size: 48px;
margin-bottom: 20px;
}
.banner p {
font-size: 24px;
margin-bottom: 20px;
}
.banner a {
background-color: #fff;
color: #333;
padding: 10px 20px;
border-radius: 5px;
text-decoration: none;
}
.pets {
padding: 50px 0;
text-align: center;
}
.pets h2 {
font-size: 36px;
margin-bottom: 20px;
}
.pets ul {
display: flex;
justify-content: center;
align-items: center;
list-style: none;
}
.pets li {
margin-right: 50px;
}
.pets li:last-child {
margin-right: 0;
}
.pets img {
width: 200px;
height: 200px;
border-radius: 50%;
margin-bottom: 10px;
}
.pets h3 {
font-size: 24px;
margin-bottom: 10px;
}
.pets p {
font-size: 20px;
margin-bottom: 10px;
}
.pets a {
background-color: #333;
color: #fff;
padding: 10px 20px;
border-radius: 5px;
text-decoration: none;
}
```
您可以根据自己的需求进行修改和美化。
阅读全文