flex实现如下布局
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.flex-box {
width: 200px;
height: 200px;
background-color: green;
display: flex;
justify-content: space-between; /*定义项目在主轴上的对齐方式 */
}
.flex-item-box {
width: 50px;
height: 50px;
background-color: red;
}
.flex-item-box:nth-child(2) {
align-self: flex-end;
}
</style>
</head>
<body>
<div class="flex-box">
<div class="flex-item-box"></div>
<div class="flex-item-box"></div>
</div>
</body>
</html>