Detect text-overflow has worked and add tooltip containing full text

前端 未结 1 1049
猫巷女王i
猫巷女王i 2021-01-03 11:15

I have a simple span containing an email address.

dave@davemail.dave

In my CSS, the span is set to a

1条回答
  •  [愿得一人]
    2021-01-03 11:37

    You can't detect an overflow with CSS. But using JavaScript it's simply this:

    JavaScript

    var e = document.getElementById('email');
    
    if (e.scrollWidth > e.clientWidth) {
        alert("Overflow");
    }
    

    Demo

    Try before buy

    0 讨论(0)
提交回复
热议问题