p{
width: 300px;
margin: 0 auto;
}
span{
display: inline-block;
}
.left{
width: 40%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
<p class="test">
<span class="left">TestTestTestTest</span>
<span class="right">Test</span>
</p>
And then it will display like
this,
I think the reason why display like this maybe the property 'overflow: hidden
' created a bfc, so I set the property 'overflow: hidden
' or 'float: right
' for '.right', and then '.right' align to '.left'.
but I've seen description of BFC from MDN, it says that display:inline-block
will creating a BFC, So the BFC of each span tags should already be created because of the css rule span {display: inline-block}
, but why they are not align before I set the properties for '.right' ?
finally,please don't focus on my poor English, I just wanna find the answer for the question I've met, and I think I will get it by this way . Thank you!
O(∩_∩)O~