<form action="shopinsert.jsp"> 商品编号:<input type="text" name="id" placeholder="选填"/> 商品名称:<input type="text" name="name" /><br> 商品价格:<input type="text" name="price" /> 所属店铺:<input type="text" name="detail" /><br> 详细信息:<input type="text" name="info" /><br><br> <input type="submit" value="添加" />如何美化这段代码
时间: 2023-07-03 16:18:01 浏览: 176
你可以使用 CSS 样式来美化这段代码,例如:
```html
<form action="shopinsert.jsp" class="my-form">
<div class="form-group">
<label for="id">商品编号:</label>
<input type="text" name="id" id="id" placeholder="选填" class="form-control" />
</div>
<div class="form-group">
<label for="name">商品名称:</label>
<input type="text" name="name" id="name" class="form-control" />
</div>
<div class="form-group">
<label for="price">商品价格:</label>
<input type="text" name="price" id="price" class="form-control" />
</div>
<div class="form-group">
<label for="detail">所属店铺:</label>
<input type="text" name="detail" id="detail" class="form-control" />
</div>
<div class="form-group">
<label for="info">详细信息:</label>
<input type="text" name="info" id="info" class="form-control" />
</div>
<div class="form-group">
<input type="submit" value="添加" class="btn btn-primary" />
</div>
</form>
```
```css
.my-form {
max-width: 500px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-group {
margin-bottom: 10px;
}
label {
display: inline-block;
width: 120px;
font-weight: bold;
color: #333;
}
.form-control {
width: 300px;
padding: 8px;
border: 1px solid #ccc;
border-radius: 5px;
}
.btn {
padding: 8px 16px;
border: none;
border-radius: 5px;
color: #fff;
background-color: #007bff;
}
.btn:hover {
background-color: #0069d9;
}
```
这样就可以使表单更加美观和易读,同时也方便修改样式。
阅读全文