The problem of ellipsis style of indefinite length text with border


<div class="parent">
    <div class="div1"></div>
    <div class="div2">
        <span class="tag"></span>
    </div>
</div>

.parent {
    width: 200px;
    display: flex;
    border: 1px solid pink;
}
.tag {
    border: 1px solid skyblue;
}

ask CSS to achieve the effect shown in the picture

ordinary ellipsis will definitely fail. If omitted on div2, the right side of blue border will also be truncated and will have no effect on tag.

Css
Jan.25,2022

display:block;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;

solved the omission failure of
on tag mainly by setting min-width, on the parent element, which is a common problem in the combination of flex and ellipsis.

.parent {
    width: 200px;
    display: flex;
    border: 1px solid pink;
}
.div2 {
    flex: 1;
    min-width: 0;
}
.tag {
    border: 1px solid skyblue;
    display: inline-block;
    max-width: 100%;
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap;
}


set the width of the parent element and set overflow: hidden;text-overflow: ellipsis;white-space: nowrap;

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ec81-2c46b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ec81-2c46b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?