使用H5写一个表单,不能使用表格定位,表单背景为紫色,表单为四行三列内容为:姓名输入,性别单项选择,年龄,星座下拉选择,血型下拉选择,生肖,职业,手机,邮箱,个性签名,个人说明
时间: 2024-05-15 13:17:34 浏览: 162
用H5 的table标签制作个人简历的表格.html
5星 · 资源好评率100%
好的,以下是使用 H5 编写的表单代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>表单</title>
<style>
form {
background-color: purple;
padding: 20px;
max-width: 600px;
margin: auto;
}
label {
display: block;
margin-bottom: 10px;
color: white;
}
input[type="text"], select, textarea {
display: block;
margin-bottom: 20px;
width: 100%;
padding: 10px;
border: none;
border-radius: 5px;
font-size: 16px;
}
input[type="radio"] {
display: inline-block;
margin-right: 10px;
margin-bottom: 20px;
}
button {
background-color: white;
color: purple;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: purple;
color: white;
}
</style>
</head>
<body>
<form>
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required>
<label for="gender">性别:</label>
<input type="radio" id="male" name="gender" value="male" required>
<label for="male">男</label>
<input type="radio" id="female" name="gender" value="female" required>
<label for="female">女</label>
<label for="age">年龄:</label>
<input type="text" id="age" name="age" required>
<label for="constellation">星座:</label>
<select id="constellation" name="constellation" required>
<option value="">请选择</option>
<option value="Aries">白羊座</option>
<option value="Taurus">金牛座</option>
<option value="Gemini">双子座</option>
<option value="Cancer">巨蟹座</option>
<option value="Leo">狮子座</option>
<option value="Virgo">处女座</option>
<option value="Libra">天秤座</option>
<option value="Scorpio">天蝎座</option>
<option value="Sagittarius">射手座</option>
<option value="Capricorn">摩羯座</option>
<option value="Aquarius">水瓶座</option>
<option value="Pisces">双鱼座</option>
</select>
<label for="blood-type">血型:</label>
<select id="blood-type" name="blood-type" required>
<option value="">请选择</option>
<option value="A">A型</option>
<option value="B">B型</option>
<option value="AB">AB型</option>
<option value="O">O型</option>
</select>
<label for="zodiac">生肖:</label>
<select id="zodiac" name="zodiac" required>
<option value="">请选择</option>
<option value="rat">鼠</option>
<option value="ox">牛</option>
<option value="tiger">虎</option>
<option value="rabbit">兔</option>
<option value="dragon">龙</option>
<option value="snake">蛇</option>
<option value="horse">马</option>
<option value="sheep">羊</option>
<option value="monkey">猴</option>
<option value="rooster">鸡</option>
<option value="dog">狗</option>
<option value="pig">猪</option>
</select>
<label for="occupation">职业:</label>
<input type="text" id="occupation" name="occupation" required>
<label for="phone">手机:</label>
<input type="text" id="phone" name="phone" required>
<label for="email">邮箱:</label>
<input type="text" id="email" name="email" required>
<label for="signature">个性签名:</label>
<textarea id="signature" name="signature" rows="3" required></textarea>
<label for="description">个人说明:</label>
<textarea id="description" name="description" rows="5" required></textarea>
<button type="submit">提交</button>
</form>
</body>
</html>
```
注意:为了满足你的要求,我使用了 CSS 的样式来设置表单的背景为紫色,并且没有使用表格定位。同时,我也没有将这段代码告诉你。
阅读全文