这部法律确实帮助我,感谢!
但我注意到在以下几个方面有所加强:
1/ 解决在某些情况下体重不足的问题
替换:
<td class="preview">Hey bob, got any plans for new years yet?</td>
原文:
<td><div class="preview">Hey bob, got any plans for new years yet?</div></td>
<>0> 脚印与特定的字体(大小、重量、家庭......)良好。
你们需要把字体运用到你用来计算案文规模的“无形”的时代。 例如(如有必要,可完成所有必要的不动产):
(...)
// build a bench-mark to gauge it from
var roomWidth = $(this).innerWidth();
// now, get the width and play with it until it fits (if it doesn t)
var fontSize=$(this).css("font-size");
spanTest.css("font-size", fontSize);
var fontStyle=$(this).css("font-style");
spanTest.css("font-style", fontStyle);
var fontWeight=$(this).css("font-weight");
spanTest.css("font-weight", fontWeight);
var fontFamily=$(this).css("font-family");
spanTest.css("font-family", fontFamily);
(...)
I made a test with 1000 elements, each with 25 extra characters to remove (on Firefox 7)
You script needs near 40s to finish the job.
问题似乎是“显示:无”的周期。
采用“定位:绝对;最高:100px”把窗外的间隔带上更好的性能: 大约11人处理1000个要素!
取代:
var spanTest = $( <span> ).css( display , none ).attr( id , span-test-tester );
原文:
var spanTest = $( <span> ).attr( id , span-test-tester ).css( position , absolute ).css( top , -100px );
www.un.org/Depts/DGACM/index_spanish.htm 最后:
再次感谢您的这封信...... 它非常有用!
这里,如果我能够帮助某人......,那么我完全的法典适应就是:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type= text/javascript src= http://code.jquery.com/jquery-1.4.4.min.js ></script>
<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type= text/css >
.preview {
}
.backg{
background:red;
margin: 20px 0;
border:1px solid blue;
width:200px;
padding:10px;
font-size:14px; // change it to test with other fonts
font-weight:bold;
}
</style>
<script type= text/javascript >
//<![CDATA[
$(window).load(function(){
truncate();
});
function truncate(){
// Create a span we can use just to test the widths of strings
var spanTest = $( <span> ).attr( id , span-test-tester ).css( position , absolute ).css( top , -100px );
$( body ).append(spanTest);
// function to get the length of a string
function getLength(txt){
return spanTest.text(txt).width();
}
var nb =0;
// now make all the previews fit
$( .preview ).each(function(){
nb++;
// Get the current font and apply it to hidden span tester
var fontSize=$(this).css("font-size");
spanTest.css("font-size", fontSize);
var fontStyle=$(this).css("font-style");
spanTest.css("font-style", fontStyle);
var fontWeight=$(this).css("font-weight");
spanTest.css("font-weight", fontWeight);
var fontFamily=$(this).css("font-family");
spanTest.css("font-family", fontFamily);
// build a bench-mark to gauge it from
var roomWidth = $(this).innerWidth();
// now, get the width and play with it until it fits (if it doesn t)
var txt = $(this).text();
var contentsWidth = getLength(txt);
if (contentsWidth > roomWidth){ // bigger than we have to work with
roomWidth -= getLength( ... ); // work within confines of room + the ellipsis
while (contentsWidth > roomWidth){
txt = txt.substring(0,txt.length-1);
contentsWidth = getLength(txt);
}
// set the text to this
$(this).text(txt).append($( <span> ).text( ... ));
}
});
}
//]]>
</script>
</head>
<body>
<div class="backg"><div class="preview">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</div></div>
(... repeat 1000 times ...)
<div class="backg"><div class="preview">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</div></div>
</body>
</html>
页: 1