html,
body {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
}
body {
display: flex;
flex-direction: column;
}
.title {
margin: 20px;
margin-bottom: 50px;
/* Adds additional space at the bottom */
padding: 10px;
border: 6px solid black;
/* Add a rectangle (border) around the container */
display: inline-block;
/* Shrink to fit the content */
text-align: right;
width: fit-content;
}
.title h1 {
margin: 5px 0;
/* Margin between each h1 element */
white-space: nowrap;
/* Prevent line breaks, keep h1 on one line */
}
.content {
flex: 1;
margin: 20px;
text-align: left;
}
.bottom {
margin: 20px;
margin-bottom: 50px;
/* Adds additional space at the bottom */
padding: 10px;
border: 6px solid black;
/* Add a rectangle (border) around the container */
display: inline-block;
/* Shrink to fit the content */
text-align: left;
width: fit-content;
}
.bottom h1 {
margin: 5px 0;
/* Margin between each h1 element */
white-space: nowrap;
/* Prevent line breaks, keep h1 on one line */
}
使用 align-self: flex-end; 而 text-align: right 不是 .title ,它是一个弹性子项(即 的直接子项 body ,它是一个弹性容器),因此响应该设置。
html,
body {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
}
body {
display: flex;
flex-direction: column;
}
.title {
margin: 20px;
margin-bottom: 50px;
/* Adds additional space at the bottom */
padding: 10px;
border: 6px solid black;
/* Add a rectangle (border) around the container */
display: inline-block;
/* Shrink to fit the content */
width: fit-content;
align-self: flex-end;
}
.title h1 {
margin: 5px 0;
/* Margin between each h1 element */
white-space: nowrap;
/* Prevent line breaks, keep h1 on one line */
}
.content {
flex: 1;
margin: 20px;
text-align: left;
}
.bottom {
margin: 20px;
margin-bottom: 50px;
/* Adds additional space at the bottom */
padding: 10px;
border: 6px solid black;
/* Add a rectangle (border) around the container */
display: inline-block;
/* Shrink to fit the content */
text-align: left;
width: fit-content;
}
.bottom h1 {
margin: 5px 0;
/* Margin between each h1 element */
white-space: nowrap;
/* Prevent line breaks, keep h1 on one line */
}