判断文本一行文本是不是溢出的方法 ,常用于查看更多
.text_wrapper{ height: 20px; line-height: 20px; width: 150px; border: 1px salmon solid; font-size: 16px; color: #1c1c1c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }<div style="height: 200px;width: 200px;display: table-cell;vertical-align: middle;">
<div class="text_wrapper">大姐夫地方健爱的色放</div>
</div>let ele = document.querySelector(".text_wrapper");
console.info(ele.innerHTML)
console.info(ele.scrollWidth);
console.info(ele.offsetWidth);
let scrollWidth = ele.scrollWidth;
let offsetWidth = ele.offsetWidth;
if(scrollWidth>offsetWidth){
alert("文本溢出")
}