文字超出 ,字体缩小以显示完整
window.onload = function () { var divHeight = document.getElementById('chenqi').clientWidth//获取容器固定宽度 var scrollWidth = document.getElementById('chenqi').scrollWidth//获取容器内容超出总宽度 console.log('chenqi',divHeight) console.log('chenqi',scrollWidth) console.log('chenqi') // debugger // var i = 1 while (scrollWidth > divHeight) { document.getElementById('chenqi').style.fontSize = 1 - i divHeight = document.getElementById('chenqi').clientWidth i++ } }
未闻花名