我有一個HTML DIV `jQuery的添加儘可能多的跨度,因爲它需要填補一個div
<div class="words_padding">
</div>
即800像素和我有這個jQuery陣列
var words=["thing","my","low","life","that","repeat","his","meaning","if","she","he","never","tell","part","tubes","how","should","come","off","on","it","about","me","and","do","same","put","country","math","like"];
我要填寫與div相同的跨度可以在沒有越界的情況下進行。
我試圖用做它的這樣
for (var i = 0; i <= 8; i++) {
$('.words_padding').append("<span class=\"words_totp\">"+words[Math.floor((Math.random() * words.length))]+"</span>");
}
但使其熄滅邊界 的jsfiddle有些話是比其他時間要長:https://jsfiddle.net/2yxvg5ye/2/
我不是e除非你的字體大小非常大,否則8個單詞可以填充800px寬。你有這樣一個可以向我們展示的工作例子嗎? –
@RoryMcCrossan它是相當大,'38px',並且還有填充從雙方'10px'.I我現在正在jsfiddle –
我不確定這是否正是你想要的,但最簡單的方法*將給容器「overflow:hidden」並將其設置爲一行文本的高度:https://jsfiddle.net/2yxvg5ye/3/ –