请问怎么让section里面的内容水平居中,label 和input相对于section居中
来源:3-1 结构标签
qq_慕标2503495
2020-03-02 14:45:21
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
*{
margin:0;
padding:0;
}
body{
background:skyblue;
}
section{
width:250px;
height:200px;
margin:50px auto;
background:#eee;
border-radius:10px;
}
label~ input{
margin-top:20px ;
margin-right:25px;
}
input{
border-radius:5px;
border:1px solid gray;
height:25px;
}
input:last-child
{
width:100px;
margin: 20px 75px;
background:blue;
}
</style>
</head>
<body>
<section>
<form method="post">
<label>账号:</label>
<input type="text" placeholder="请输入账号">
<br/>
<label>密码:</label>
<input type="text" placeholder="请输入密码">
<br/>
<label>班级:</label>
<input placeholder="请输入班级" list="classlist" type="text">
<datalist id="classlist">
<option value="17计科">17计科</option>
<option value="17软件">17软件</option>
<option value="17电商">17电商</option>
</datalist>
<br/>
<input type="submit" value="提交">
</form>
</section>
</body>
</html>
1回答
同学你好,是label 和input整体居中吗?
可以去掉input的右外边距值,直接给section添加内容居中属性,例:
如果我的回答帮助了你,欢迎采纳,祝学习愉快~
相似问题
回答 3
回答 1