Css 如何仅将flexbox宽度设置为
如何将flexbox容器的宽度设置为其中内容的宽度?它是否可以像Css 如何仅将flexbox宽度设置为,css,flexbox,Css,Flexbox,如何将flexbox容器的宽度设置为其中内容的宽度?它是否可以像display:inline block,而不指定固定宽度 试试这个 .parent { width: 150px; height: 150px; background: yellow; text-align: center; } .flex { display: inline-flex; margin: auto; justify-content: center; b
display:inline block
,而不指定固定宽度
试试这个
.parent {
width: 150px;
height: 150px;
background: yellow;
text-align: center;
}
.flex {
display: inline-flex;
margin: auto;
justify-content: center;
background: blue;
}
尝试
inlineflex