普通的前端购物页面代码
时间: 2023-08-30 20:12:31 浏览: 51
以下是一个简单的前端购物页面的HTML和CSS代码示例:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>购物页面</title>
<link rel="stylesheet" type="text/css" 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>
<h2>产品列表</h2>
<ul>
<li>
<img src="product1.jpg">
<h3>商品名称1</h3>
<p>商品描述1</p>
<button>加入购物车</button>
</li>
<li>
<img src="product2.jpg">
<h3>商品名称2</h3>
<p>商品描述2</p>
<button>加入购物车</button>
</li>
<li>
<img src="product3.jpg">
<h3>商品名称3</h3>
<p>商品描述3</p>
<button>加入购物车</button>
</li>
</ul>
</section>
<aside>
<h2>购物车</h2>
<ul>
<li>商品名称1</li>
<li>商品名称2</li>
<li>商品名称3</li>
</ul>
<button>结算</button>
</aside>
</main>
<footer>
<p>版权所有 © 2021 购物页面</p>
</footer>
</body>
</html>
```
CSS代码:
```css
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
nav ul {
list-style: none;
}
nav ul li {
display: inline-block;
margin-right: 20px;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
main {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
section {
flex: 2;
}
section ul {
list-style: none;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
section li {
width: 30%;
margin-bottom: 20px;
border: 1px solid #ccc;
padding: 10px;
text-align: center;
}
section li img {
width: 100%;
}
section li h3 {
margin-top: 10px;
}
section li p {
margin-top: 5px;
}
section li button {
background-color: #333;
color: #fff;
border: none;
padding: 10px 20px;
margin-top: 10px;
cursor: pointer;
}
aside {
flex: 1;
background-color: #eee;
padding: 20px;
}
aside ul {
list-style: none;
margin-bottom: 20px;
}
aside button {
background-color: #333;
color: #fff;
border: none;
padding: 10px 20px;
cursor: pointer;
}
footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
```
注意:这只是一个简单的示例,实际应用中可能需要根据具体的业务需求进行修改和定制化。