我有一段包含大約100個單詞。我想限制每行的最大字數爲10
。我在CSS中使用了寬度屬性,但是當字體大小減少時,限制超過了。我怎樣才能限制每行的文字?任何幫助,將不勝感激。如何限制html段落中每行的字數?
實施例:
<p>The key takeaway for understanding the shift towards VR & AR is their collective push towards enabling people to engage more naturally with computers — by simply looking, gesturing, conversing, and being — as opposed to dealing with interfering and unnatural interfaces like mice, keyboards, and flat screens. Less interference means more immersion. And more immersion means more humanity, empathy, and potential for transformation in our experience — both relating to computers, and to each-other.</p>
輸出應該是一個HTML段,每行只有10個字:
The key takeaway for understanding the shift towards VR & AR is their collective push towards enabling people to engage more naturally with computers — by simply looking, gesturing, conversing, and being — as opposed to dealing with interfering and unnatural interfaces like mice, keyboards, and flat screens. Less interference means more immersion. And more immersion means more humanity, empathy, and potential for transformation in our experience — both relating to computers, and to each-other.
您是否嘗試在每10個單詞或其他內容中添加「\ n」? – dloeda
爲什麼不用substring將文本與for匹配,然後將它重新放回\ n,如dloeda所說的那樣? – EnriqueDev
感謝您的幫助 – Dark