2 回答
TA贡献1817条经验 获得超14个赞
从您的描述来看,您似乎正在使用 Edge Legacy。width: fit-content
Edge Legacy 不支持,但 Edge Chromium 支持,您可以在caniuse上查看。
一种替代方法是使用display: table
,其效果与以下相同width: fit-content
:
.tileContainer {
margin: 25px;
height: 120px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
border: 1px solid black;
border-radius: 5px;
box-shadow: solid 0.2px #d2d3d3;
}
.tileContainer .leftSideContent {
display: flex;
flex-direction: column;
justify-content: center;
min-width: 0;
}
.tileContainer .leftSideContent .firstLevelHeader {
background-color: #8a8a8a;
padding-left: 10px;
padding-right: 10px;
border-radius: 10px;
height: 20px;
align-content: center;
width: fit-content;
display: table; /*add this line*/
}
.tileContainer .leftSideContent .secondLevelHeader {
height: 20px;
}
.tileContainer .rightSideContent {
justify-content: center;
width: 50px;
}
<section id='tileContainer' class='tileContainer'>
<div id='leftSideContent' class='leftSideContent'>
<div id='firstLevelHeader' class='firstLevelHeader'>
First Level Header
</div>
<div id='secondLevelHeader' class='secondLevelHeader'>
Second level header has a got a very long text inside of it
</div>
</div>
<div id='rightSideContent' class='rightSideContent'>
X
</div>
</section>
- 2 回答
- 0 关注
- 151 浏览
添加回答
举报