应用Flex布局的简单练习
一、输入框布局
1.1 代码
<body>
<div class="div0">
<label>订单ID</label>
<input type="text">
<label>Go</label>
</div>
</body>
<style>
*{
margin: 0;
padding: 0;
}
.div0{
width: 300px;
display: flex;
border: 1px solid #dcdcdc;
}
.div0 label{
flex: 1;
background-color: #f5f5f5;
font-size: "楷体";
text-align: center;
}
.div0 input{
border: 0;
outline: 0;
}
</style>
1.2 页面效果展示
二、长表单布局
2.1 代码
<body>
<form>
<div class="form">
<div>
<label>账号:</label>
<input type="text">
</div>
<div>
<label>请输入密码:</label>
<input type="text">
</div>
<div>
<label>请输入再次密码:</label>
<input type="text">
</div>
</div>
</form>
</body>
<style>
.form div{
display: flex;
align-items: flex-start;
flex: 0 0 30px;
}
.form div label{
flex: 0 0 140px;
text-align: right;
}
.form{
display: flex;
flex-direction: column;
}
</style>