解释这一点的最好方法是使用示例:
<div style="width:100px;height:100px;overflow:hidden;">
<?php echo $content; ?>
</div>
如何使用 jQuery 查看是否有文本溢出?
最佳答案
比较元素的 scrollHeight
(DOM 属性,因此 .get(0)
)和 height
以检查元素的内容是否超过元素的边界与否。
var $div = $("div"); //Assume one div. Use a more specific selector
var isOverflowing = $div.get(0).scrollHeight != $div.height();
//The variable `isOverflowing` is true if the text overflows
关于php - 是否可以使用 jQuery 来确定行高?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7786729/