用HTML和css编写一个购物网站简易代码
时间: 2023-07-14 09:13:07 浏览: 152
以下是一个简单的购物网站的 HTML 和 CSS 代码,仅供参考:
HTML 代码:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>购物网站</title>
<link rel="stylesheet" href="styles.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="product">
<h2>商品名称</h2>
<img src="product.jpg" alt="商品图片">
<p>商品描述</p>
<p>价格:$99.99</p>
<button>加入购物车</button>
</section>
</main>
<footer>
<p>版权信息</p>
</footer>
</body>
</html>
```
CSS 代码:
```
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
}
nav ul {
list-style: none;
display: flex;
}
nav li {
margin-right: 20px;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.product {
margin: 20px;
padding: 20px;
background-color: #eee;
display: flex;
flex-direction: column;
align-items: center;
}
.product img {
max-width: 100%;
margin-bottom: 20px;
}
button {
background-color: #333;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
```
阅读全文