我正在尝试使用jQuery计算文本宽度.我不确定是什么,但我肯定做错了什么.
所以,这是代码:
var c = $('.calltoaction');
var cTxt = c.text();
var cWidth = cTxt.outerWidth();
c.css('width' , cWidth);
Run Code Online (Sandbox Code Playgroud) 如何检测div元素中的垂直文本溢出?
CSS:
div.rounded {
background-color:#FFF;
height: 123px;
width:200px;
font-size:11px;
overflow:hidden;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="tempDiv" class="rounded">
Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Phasellus vel quam vestibulum orci blandit laoreet.
</div>
Run Code Online (Sandbox Code Playgroud)