gpt4 book ai didi

html - 对齐 self 拉伸(stretch)不起作用?

转载 作者:可可西里 更新时间:2023-11-01 13:49:16 25 4
gpt4 key购买 nike

你好,我正在练习 CSS flexbox ,一切都很顺利,但是当我尝试使用 align-self 属性时,它的所有值都像 flex-start 、 flex-end 、 center 等一样工作,但是拉伸(stretch)在这里不起作用是代码

#flexcontainer {
border: 3px solid black;
display: flex;
flex-wrap: wrap;
height: 450px;
justify-content: space-around;
max-width: 500px;
margin: 150px auto;
}
.flexitem {
background: yellow;
width: 48%;
height: 115px;
text-align: center;
line-height: 115px;
}
.one {
align-self: stretch;
}
<div id="flexcontainer">
<div class="flexitem one">1</div>
<div class="flexitem two">2</div>
</div>

最佳答案

问题已修复 .flexitem 上的 height,因此您可以用 height: auto 覆盖

 #flexcontainer {
border: 3px solid black;
display: flex;
flex-wrap: wrap;
height: 450px;
justify-content: space-around;
max-width: 500px;
margin: 150px auto;
}
.flexitem {
background: yellow;
width: 48%;
height: 115px;
text-align: center;
line-height: 115px;
}
.one {
height: auto;
}
<div id="flexcontainer">
<div class="flexitem one">1</div>
<div class="flexitem two">2</div>
</div>

关于html - 对齐 self 拉伸(stretch)不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36985273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com