【发布时间】:2013-12-01 22:05:03
【问题描述】:
我正在尝试理解弹性框: 我想让“第一个”块拉伸以匹配浏览器的整个宽度,而“第二个”块的大小固定并左对齐。
所以我在父级(<html>)中使用了align-items: flex-end,并尝试在“第一个”块中使用align-self: stretch 拉伸第一个块。
这不起作用。它们都向左对齐。
<html>
<head>
<style>
html {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-end;
}
#first {
align-self:stretch;
background-color: red;
border: 3px solid black;
}
#second {
background-color:green;
width: 300px;
height: 400px;
border: 3px solid yellow;
}
</style>
</head>
<body>
<div id="first">This is first</div>
<div id="second">This is second</div>
</body>
</html>
【问题讨论】: