請你幫我用css美化這段代碼,左邊為菜單欄位,右邊為表單,表單不要太大請依次排列。另外優化vug
时间: 2024-03-22 16:41:29 浏览: 21
好的,以下是使用 CSS 对该段代码进行美化的示例代码:
HTML 代码:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>异常记录</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
<div id="menu">
<ul>
<li><a href="/">首页</a></li>
<li><a href="/index2">登记数据</a></li>
<li><a href="/history">查询数据</a></li>
<li><a href="/chart">查询数据</a></li>
</ul>
</div>
<div id="main">
<h1>异常记录登记</h1>
<form method="post" action="/submit">
<div class="form-row">
<label for="line">确认线别:</label>
<input name="line" class="layui-input" placeholder="请选择线别" />
</div>
<div class="form-row">
<label for="date">确认日期:</label>
<input type="date" name="date" id="date" />
</div>
<div class="form-row">
<label for="model">异常机种:</label>
<input type="text" name="model" id="model" placeholder="请输入机种"/>
</div>
<div class="form-row">
<label for="prod_line">异常现象:</label>
<input type="text" name="prod_line" id="prod_line" placeholder="请输入现象">
</div>
<div class="form-row">
<label for="prod_date">生产日期:</label>
<input type="date" name="prod_date" id="prod_date">
</div>
<div class="form-row">
<label for="shift">生产班别:</label>
<select name="shift" id="shift">
<option value="白班">白班</option>
<option value="夜班">夜班</option>
</select>
</div>
<div class="form-row">
<label for="prod_line_2">生产线别:</label>
<input type="text" name="prod_line_2" id="prod_line_2">
</div>
<div class="form-row">
<label for="responsible">责任人:</label>
<input type="text" name="responsible" id="responsible" placeholder="请输入责任人">
</div>
<div class="form-row">
<button type="submit">提交</button>
</div>
</form>
</div>
</div>
</body>
</html>
```
CSS 代码:
```
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, sans-serif;
}
.wrapper {
display: flex;
flex-direction: row;
}
#menu {
width: 20%;
background-color: #f5f5f5;
padding: 20px;
}
#menu ul {
list-style: none;
}
#menu li {
margin-bottom: 10px;
}
#menu a {
text-decoration: none;
color: #333;
font-weight: bold;
}
#main {
width: 80%;
padding: 20px;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
}
.form-row {
margin-bottom: 20px;
}
label {
display: inline-block;
width: 20%;
text-align: right;
margin-right: 20px;
font-weight: bold;
}
input[type="text"],
input[type="date"],
select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 60%;
}
button[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
margin-top: 20px;
}
```
主要的美化工作包括:
- 使用 flexbox 布局,将菜单和表单放在同一行,并占据不同的宽度。
- 对菜单进行样式设置,包括设置背景色、内边距、列表样式等。
- 对表单进行样式设置,包括设置输入框、下拉框、按钮等的样式和布局。
- 将输入框的标签和输入框布局在同一行,使用 label 标签实现,并设置合适的样式。
- 对提交按钮进行样式设置,包括设置背景色、字体颜色、边框等。
至于优化 Vue,需要具体问题具体分析,需要更多的上下文信息和具体的需求。