如何阻止动态数据超出表的溢出?

发布于 2024-09-24 00:04:33 字数 568 浏览 1 评论 0原文

这是一个Struts 应用程序。 我必须在左侧面板中显示从数据库或任何会话对象(例如注释)检索的动态日期。 如果单词之间有空格,那么它就可以正常工作。 但是,在测试我是否输入一些没有空格的字符时,在左侧面板中显示数据时,数据会穿过表格并出现在 IE8、Mozilla 和 chrome 的主面板上。

我的部分示例代码是这样的。

<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="fixedTable">
<tr>
 <td class="normalTxt" width="100" style="text-align:left;"
   bean:write name="cNotesInfo" property="description" /> 
 </td>
</tr>
</table>

请任何解决方案。

我已经删除了 //>符号使您输入代码

It's a Struts application.
I have to show some dynamic date in the left hand panel retrieving from DB or any session object e.g Notes.
If there is space between words then its working fine.
But while testing if I am entering some characters without space, then while showing the data in Left hand panel is crossing the table and coming on main panel in IE8, Mozilla and chrome also.

My part of sample code is like this.

<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="fixedTable">
<tr>
 <td class="normalTxt" width="100" style="text-align:left;"
   bean:write name="cNotesInfo" property="description" /> 
 </td>
</tr>
</table>

Any solution please.

I have removed the < / > symbol to make U sho the code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骷髅 2024-10-01 00:04:33

您可以在渲染到屏幕之前向数据添加一个空格。
<代码>

string Data = "areallylongstringthatisgoingtobreakyouroutputresult"
if(Data.Length > 50 && !Data.Contains(' ')){
    Data.insertAfter(25,' ');
}

IE 5.5+、Firefox 3.5+ 以及 WebKit 浏览器(例如 Chrome 和 Safari)支持自动换行。
<代码>

.break-word {
  word-wrap: break-word;
}

One important note - if the element has a fixed width this approach works well. However if you have width 100% this doesn’t do the job

You could add a space to your data before rendering to the screen.

string Data = "areallylongstringthatisgoingtobreakyouroutputresult"
if(Data.Length > 50 && !Data.Contains(' ')){
    Data.insertAfter(25,' ');
}

Also there is this for selected browsers.. Word-wrap is supported in IE 5.5+, Firefox 3.5+, and WebKit browsers such as Chrome and Safari.

.break-word {
  word-wrap: break-word;
}


One important note - if the element has a fixed width this approach works well. However if you have width 100% this doesn’t do the job

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文