可以写一个商品购买界面吗?使用html,css
时间: 2024-05-22 22:12:32 浏览: 9
可以的,以下是一个简单的商品购买界面的 HTML 和 CSS 代码:
HTML 代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>商品购买界面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>商品购买</h1>
<div class="product">
<img src="https://via.placeholder.com/150" alt="Product Image">
<h2>商品名称</h2>
<p class="price">$99.99</p>
<p class="description">商品描述</p>
<form action="#" method="post">
<label for="quantity">数量:</label>
<input type="number" id="quantity" name="quantity" min="1" value="1">
<button type="submit">加入购物车</button>
</form>
</div>
</div>
</body>
</html>
```
CSS 代码:
```css
* {
box-sizing: border-box;
font-family: Arial, sans-serif;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
text-align: center;
}
.product {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
}
.product img {
margin-right: 20px;
}
.product h2 {
margin-top: 0;
}
.price {
font-weight: bold;
font-size: 24px;
margin: 10px 0;
}
.description {
margin-bottom: 20px;
}
form {
display: flex;
align-items: center;
}
label {
margin-right: 10px;
}
input[type="number"] {
width: 60px;
margin-right: 10px;
}
button {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
```
效果图如下:
![商品购买界面](https://i.imgur.com/1r8gKst.png)