html写一个css明确的购物商品主页面
时间: 2023-08-01 14:12:34 浏览: 43
好的,我会给你一个HTML和CSS的基本框架,你可以在此基础上进行修改和完善。
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>
</ul>
</nav>
</header>
<main>
<section class="product-list">
<h2>商品列表</h2>
<ul>
<li>
<img src="product1.jpg" alt="商品1">
<h3>商品1名称</h3>
<p>商品1简介</p>
<span class="price">¥ 100</span>
<button>加入购物车</button>
</li>
<li>
<img src="product2.jpg" alt="商品2">
<h3>商品2名称</h3>
<p>商品2简介</p>
<span class="price">¥ 200</span>
<button>加入购物车</button>
</li>
<li>
<img src="product3.jpg" alt="商品3">
<h3>商品3名称</h3>
<p>商品3简介</p>
<span class="price">¥ 300</span>
<button>加入购物车</button>
</li>
</ul>
</section>
</main>
<footer>
<p>版权所有 © 2021</p>
</footer>
</body>
</html>
```
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: 20px;
}
nav ul {
display: flex;
list-style: none;
}
nav ul li {
margin-right: 20px;
}
nav ul li a {
color: #fff;
text-decoration: none;
font-size: 18px;
}
main {
width: 80%;
margin: 0 auto;
}
.product-list {
margin-top: 50px;
}
.product-list h2 {
font-size: 24px;
margin-bottom: 20px;
}
.product-list ul {
display: flex;
flex-wrap: wrap;
list-style: none;
}
.product-list li {
width: 30%;
margin-right: 5%;
margin-bottom: 30px;
border: 1px solid #ccc;
padding: 20px;
}
.product-list li:last-child {
margin-right: 0;
}
.product-list li img {
width: 100%;
}
.product-list li h3 {
font-size: 18px;
margin-top: 10px;
margin-bottom: 10px;
}
.product-list li p {
margin-bottom: 10px;
}
.product-list li .price {
font-size: 20px;
color: #f00;
margin-right: 10px;
}
.product-list li button {
background-color: #f00;
color: #fff;
border: none;
padding: 10px 20px;
cursor: pointer;
font-size: 16px;
transition: all 0.3s ease-in-out;
}
.product-list li button:hover {
background-color: #fff;
color: #f00;
}
```
以上代码实现了一个简单的商品列表页面,包括导航栏、商品列表、商品图片、商品名称、商品简介、商品价格和加入购物车按钮等功能。你可以根据实际需求进行修改和完善。