How can I mimic text-overflow: ellipsis in Firefox?

前端 未结 13 1162
抹茶落季
抹茶落季 2020-12-15 19:04

I have some dynamic text contained in a div that is set to whatever a user enters in a textbox field. If the text doesn\'t fit in the div, right now it just gets cut off at

13条回答
  •  离开以前
    2020-12-15 19:22

    This issue must be working on Firefox too.

    HTML

    Here goes too long text and when it is takes more than 200px in "end" of the text appears "..."

    CSS

    .ellipsis{
    width:200px;
    text-overflow:ellipsis;
    -o-text-overflow:ellipsis;
    -moz-binding:url('bindings.xml#ellipsis');//issue for Firefox
    }
    

    bindings.xml

    
    
        
    
    
        
            
        
        
            document.getAnonymousNodes(this)[0]
            this.label.style
            
                this.style.display
                if(this.style.display!= val)this.style.display=val
            
            
                this.label.value
                if(this.label.value!=val)this.label.value=val
            
            
                
                    var strings= this.textContent.split(/\s+/g)
                    if(!strings[0])strings.shift()
                    if(!strings[strings.length-1])strings.pop()
                    this.value=strings.join('')
                    this.display=strings.length?'':'none'
                
            
            this.update()
        
        
            this.update()
        
    
    
    

提交回复
热议问题