Text overflow ellipsis not showing with some custom font

前端 未结 7 912
傲寒
傲寒 2021-01-17 09:08

I\'m currently trying to make a text box with hiding overflowing text. It works fine, but for some part. I\'m using

text-overflow: ellipsis;
<
7条回答
  •  长情又很酷
    2021-01-17 09:34

    So, I know this isn't ideal but it is a work-around. The CSS3 specification says that the ellipsis must take their style from the container that they're in. This works correctly in all browsers except IE8/9 which takes it's ellipsis style from the first letter of the container. The work-around I propose is to wrap the text inside of your "overflowed" elements with an inline element, give the outer container a font where the ellipsis character is defined and give the inline element inside your custom font. It would look something like this fiddle: http://jsfiddle.net/u9dudost/2/

    If you need to add IE8/9 support, add the following:

    div {
        white-space: nowrap;
    }
    
    div::before {
        font-family: 'Helvetica', sans-serif; /* Your custom font here. */
        content: ''; /* IE9 fix */
    }
    

提交回复
热议问题