html部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>表单</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<form action="" class="container">
<h1>用户注册</h1>
<div class="formItem">
<input class="txt" type="text" placeholder="请输入11位手机号" maxlength="11">
</div>
<div class="formItem clearfix captcha">
<input class="txt left" type="text" placeholder="请填写验证码">
<button class="right" type="button" disabled>发送验证码</button>
</div>
<div class="formItem">
<input class="txt" type="password" placeholder="请输入密码">
</div>
<div class="formItem">
<input class="txt" type="password" placeholder="请再次输入密码">
</div>
<div class="formItem">
<select name="" id="" multiple class="txt">
<option>爱好1</option>
<option>爱好2</option>
<option>爱好3</option>
<option>爱好4</option>
<option>爱好5</option>
<option>爱好6</option>
<option>爱好7</option>
<option>爱好8</option>
<option>爱好9</option>
<option>爱好10</option>
</select>
</div>
<div class="formItem clearfix">
<div class="title left">性别</div>
<div class="left">
<label>
<input type="radio" checked name="sex">
<span>男</span>
</label>
<label>
<input type="radio" name="sex">
<span>女</span>
</label>
</div>
</div>
<div class="formItem">
<textarea class="txt" name="" id="" placeholder="请填写个人简介"></textarea>
</div>
<div class="formItem policy">
<label>
<input type="checkbox" name="" id="">
<span class="content">同意</span>
</label>
</div>
<div class="formItem">
<button>立即注册</button>
<button type="reset">重置表单</button>
</div>
</form>
</body>
</html>
css部分
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
background: #081623;
color: #333;
}
.container {
width: 400px;
margin: 30px auto;
border-radius: 10px;
padding: 20px;
background: #fff;
}
.container h1 {
text-align: center;
margin-bottom: 30px;
}
.formItem {
margin-bottom: 10px;
}
/*设置文本框的统一样式*/
.txt {
width: 100%;
padding: 10px;
border-radius: 5px;
font-size: 14px;
outline: none;
height: 40px;
border: 1px solid #ccc;
}
.txt:focus {
border-color: #5f8be8;
}
select.txt {
height: 100px;
padding: 10px;
}
textarea.txt {
resize: none;
height: 100px;
padding: 10px;
}
button {
outline: none;
border: none;
height: 40px;
width: 150px;
font-size: 15px;
border-radius: 5px;
color: #fff;
background-color: #5f8be8;
cursor: pointer;
}
button:hover {
background-color: #93b1f2;
}
button:disabled {
background-color: #c8d5f1;
cursor: not-allowed;
}
/*处理浮动元素*/
.left {
float: left;
}
.right {
float: right;
}
.clearfix::after {
content: "";
display: block;
clear: both;
}
.captcha .txt {
width: 170px;
}
.title {
margin-right: 10px;
}
.policy .content {
font-size: 12px;
vertical-align: 2px;
}
label {
cursor: pointer;
}
label span {
color: #aaa;
}
label input:checked~span {
color: #333;
}
input:focus::placeholder {
color: #5f8be8;
}
效果展示
