How can web pages be displayed with ellipses in the middle of super-long text on the mobile side?

the mobile page does not always display how many words are displayed because it needs to be adapted. If the text is too long, how to keep the head and tail and replace it with an ellipsis in the middle, and the total length is just enough to fill the width of the screen?

Apr.01,2021

single line

position: relative; line-height: 20px; max-height: 40px;overflow: hidden;}
p::after{content: "..."; position: absolute; bottom: 0; right: 0; padding-left: 40px;
background: -webkit-linear-gradient(left, transparent, -sharpfff 55%);
background: -o-linear-gradient(right, transparent, -sharpfff 55%);
background: -moz-linear-gradient(right, transparent, -sharpfff 55%);
background: linear-gradient(to right, transparent, -sharpfff 55%);
this method has a wide range of applications, but there will be ellipses when the text does not exceed the travel time. This method can be optimized with js.
Menu