What is the problem of text overflow caused by vertical arrangement of flex align-items:center?

if I set align-items:center, it will cause text overflow. What is the cause of this?

html

<div class="box">
    <div></div>
    

<span>hello word</span> </div>

css

.box{
    width:200px;
    height:200px;
    display:flex;
    flex-direction:column;
      
    align-items:center; /*   */
    
    border:1px solid red;
    margin:50px;
    box-sizing:border-box;
    padding:10px;
}
.box p{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

clipboard.png

jsfiddle: https://jsfiddle.net/ea54ds3v/3/

Mar.15,2022

if you write the style of p to show an ellipsis when you want to overflow, then you can add
max-width: 100% to the style of p;
where p is too long is the content overflow of box, not the content overflow of p, so the style added to p is not shown.


your text will definitely overflow if it exceeds the width of the box, unless you set overflow-x:scroll;

.
Menu