如何打破HTML中的长词? [英] how to break the long word in html?

查看:85
本文介绍了如何打破HTML中的长词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在javascript中动态创建列表。我想打破点点(.....)的长字。例如,如果单词是软件生命周期开发,我想将它改为软件生命周期....。



我使用了WORD-BREAK:BREAK-ALL; white-space:normal;
我当前的输出是:

软件生命周期
开发。



任何人都可以告诉,如何解决这个问题?感谢提前。

  var parent = document.getElementById('searchlistview'); 
var listItem = document.createElement('li');
listItem.setAttribute('id','listitem_'+ listId);
listItem.setAttribute('data-icon','false');
listItem.innerHTML =< img src =+ imagesrc +class ='ui-li-icon ui-li-has-icon'>< / img>
< a target ='_ black'data-role ='button'href ='#'id =+ listId +name =+ url +data-theme ='c'rel ='external'
data-inline = 'true'style ='margin-left:0em; WORD-BREAK:BREAK-ALL; white-space:normal;'> + searchName +< p style ='margin-top:1px; margin-left:1px;'>
文件大小:+ fileSize +< / p>< / a>;
parent.appendChild(listItem);


解决方案

您可以试试这个CSS

  text-overflow:ellipsis; 

当将 ... 文本溢出。请参阅页面以供参考。


I'm creating list dynamically in javascript. I want to break the long word in as dot dot dot(.....). For example, if the word is "Software life cycle development" I want to change it as "Software life cycl....".

And I used "WORD-BREAK:BREAK-ALL;white-space:normal;" My current output is:

Software life cycle development.

Can anyone tell, how to fix this? thanks in advance.

  var parent = document.getElementById('searchlistview');
var listItem = document.createElement('li');
listItem.setAttribute('id', 'listitem_' + listId);
listItem.setAttribute('data-icon', 'false');
listItem.innerHTML = "<img src=" + imagesrc + " class='ui-li-icon ui-li-has-icon'></img>
<a target='_black' data-role='button' href='#' id=" + listId + " name= " + url + " data-theme ='c' rel='external' 
data-inline='true' style='margin-left:0em; WORD-BREAK:BREAK-ALL;white-space:normal; ' >" + searchName + "<p style='margin-top:1px;margin-left:1px;'>
File size: " + fileSize + "</p></a>";
parent.appendChild(listItem);

解决方案

You can try this css

text-overflow:ellipsis;

It would put ... when the text overflow. see this page for your reference.

这篇关于如何打破HTML中的长词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆