用HTML和ccs实现一个简单的基本购物网页首页
时间: 2023-12-03 21:45:05 浏览: 34
好的,以下是一个简单的基本购物网页首页的HTML和CSS代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>购物网页首页</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #f1f1f1;
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
font-size: 24px;
font-weight: bold;
}
nav {
background-color: #777;
color: #fff;
padding: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
}
nav a {
color: #fff;
text-decoration: none;
margin: 0 10px;
}
nav a:hover {
color: #f1f1f1;
}
section {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
padding: 20px;
}
.product {
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
border-radius: 5px;
margin: 10px;
padding: 10px;
width: 300px;
text-align: center;
}
.product img {
width: 200px;
height: 200px;
object-fit: cover;
margin-bottom: 10px;
}
.product h3 {
font-size: 18px;
margin: 10px 0;
}
.product p {
font-size: 14px;
color: #777;
margin: 5px 0;
}
.product button {
background-color: #333;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
margin-top: 10px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.product button:hover {
background-color: #555;
}
footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>
<header>
购物网页
</header>
<nav>
<a href="#">首页</a>
<a href="#">商品</a>
<a href="#">购物车</a>
<a href="#">我的订单</a>
<a href="#">登录</a>
<a href="#">注册</a>
</nav>
<section>
<div class="product">
<img src="product1.jpg">
<h3>商品1</h3>
<p>描述商品1的信息</p>
<button>加入购物车</button>
</div>
<div class="product">
<img src="product2.jpg">
<h3>商品2</h3>
<p>描述商品2的信息</p>
<button>加入购物车</button>
</div>
<div class="product">
<img src="product3.jpg">
<h3>商品3</h3>
<p>描述商品3的信息</p>
<button>加入购物车</button>
</div>
<div class="product">
<img src="product4.jpg">
<h3>商品4</h3>
<p>描述商品4的信息</p>
<button>加入购物车</button>
</div>
</section>
<footer>
版权所有 © 购物网页
</footer>
</body>
</html>
```
请注意,这只是一个简单的示例,您可以根据您的需求修改并添加更多内容。