防止元素扩展 [英] Prevent Element from Expanding
本文介绍了防止元素扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格,其中有一列用于显示 URL,有时 URL 会变得很长.
I have a table which has a column for URLs and sometimes the URL can get pretty long.
我将表格设置为具有特定宽度,但有时 URL 甚至不会自行破坏并展开表格,从而使布局混乱.
I set the table to have a specific width but there are times when the URL wouldn't even break itself and expand the table which messes up with the layout.
这是一个 Fiddle 供您查看,我将提供以下代码:>
HTML
Here's a Fiddle for you to take a look at and I'll provide the codes below:
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td>Test</td>
<td>http://www.exampledomain.org/How-We-Work/General-Information/General-Opportunities/Open-Concept-Memo-Global-Test-Cases</td>
</tr>
</tbody>
</table>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td>Another Test</td>
<td>http://www.exampledomain.org/search?q=flagship+collaborative+research+program&btnG=Google%2BSearch&client=csiro_frontend&output=xml_no_dtd&proxystylesheet=csiro_frontend&proxyreload=0&sort=date%253AD%253AL%253Ad1&wc=200&wc_mc=1&oe=UTF-8&ie=UTF-8&ud=1&exclude_apps=1&site=Main&filter=0&getfields=*&sourcepage={CB41B120-BEE8-4511-9BED-A5E43D32381D}</td>
</tr>
</tbody>
</table>
CSS
table {
width: 500px;
margin: 5px;
}
推荐答案
https://jsfiddle.net/0xyhz7p0/1/
td {
word-break: break-word;
}
这篇关于防止元素扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文