gpt4 book ai didi

html - 自动换行不适用于 Internet Explorer 中的 flex 元素

转载 作者:行者123 更新时间:2023-11-27 23:19:26 27 4
gpt4 key购买 nike

在下面的代码中,我有一个带有嵌套 flex 列容器的 flex 行容器。在 flex 列容器中,自动换行似乎不起作用。

.profile-header {
padding-bottom: 20px;
}

.profile-header-container {
display: flex;
justify-content: center;
border: 1px solid purple;
}

.picture {
height: 175px;
width: 175px;
background-color: orange;
flex-shrink: 0;
}

.info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.name {
font-size: 24px;
border: 1px solid red;
}

.button {
height: 50px;
width: 150px;
background-color: blue;
}
<div class="profile-header">
<div class="profile-header-container">
<div class="picture">

</div>
<div class="info">
<div class="name">
reallylongfirstname reallylonglastname
</div>
<div class="button">

</div>
</div>
</div>
</div>

.name 元素似乎不想在 Internet Explorer 中进行自动换行,而在 Chrome 中似乎可以正常工作。我检查了 flex 错误,特别是错误 #2,但设置 max-width: 100% 似乎不起作用。有什么方法可以让这项工作成功吗?

jsfiddle

最佳答案

您可以使用 CSS 表格来实现相同的布局。

.profile-header {
border: 1px solid green;
}
.profile-header-container {
display: table;
margin: 0 auto;
border: 1px solid purple;
}
.picture,
.info {
display: table-cell;
vertical-align: middle;
}
.picture {
display: block;
height: 175px;
width: 175px;
background-color: orange;
}
.info {
text-align: center;
}
.name {
font-size: 24px;
border: 1px solid red;
}
.button {
display: block;
height: 50px;
width: 150px;
margin: 0 auto;
background-color: blue;
}
<div class="profile-header">
<div class="profile-header-container">
<div class="picture"></div>
<div class="info">
<div class="name">
reallyrealylongfirstname reallyreallylonglastname
</div>
<div class="button"></div>
</div>
</div>
</div>

jsFiddle

关于html - 自动换行不适用于 Internet Explorer 中的 flex 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41781897/

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