简体   繁体   English

在表格的td中换行

[英]Wraping text within a table's td

I am working on trying to clean up a customers evaluation software. 我正在努力清理客户评估软件。 In this example, the text doesn't wrap within the box. 在此示例中,文本不包装在框中。 Adding a fixed size to the table doesn't help, as the information called from the SQL database just places it on top with no warping. 在表中添加固定大小无济于事,因为从SQL数据库调用的信息只是将其放在顶部而不会发生扭曲。

    <tr>
        <td valign="bottom" align="center"><br />
            <table style="background-color: #EFEFEF; box-shadow: 5px 5px 5px #999; table-layout:fixed; width:400px" border=1 rules=none frame=box cellpadding="5">
                ![enter image description here][1]<tr><td width=250px height="90px" valign="top"><pre>' . base64_decode($eval['note']) . '</pre></td></tr>
            </table>
        </td>
    </tr>

What steps should I look at doing or code should I add to fix this formatting error? 我应该看什么步骤或应该添加代码来解决此格式错误? Attached is a screen shot of the UI. 随附的是UI的屏幕截图。

Thank you, 谢谢,

Paul 保罗

You are inserting your data inside a <pre> block, effectively telling the browser not to wrap the text. 您正在将数据插入<pre>块内,有效地告诉浏览器不要包装文本。 I assume you do this so that literal newlines in the 'note' data are indeed printed. 我假设您这样做是为了确实打印“注释”数据中的文字换行符。

To alter wrapping space-characters and newline functionality of an element, you can use the CSS white-space property. 要更改元素的换行符和换行功能,可以使用CSS空白属性。 So, to get what you want (both wrapping AND literal newlines), you can set white-space to either pre-line or pre-wrap, depending on your need. 因此,要获得所需的内容(包括换行和文字换行符),可以根据需要将空格设置为预行或换行。 Eg. 例如。 change the <pre> to 将<pre>更改为

...<pre style="white-space:pre-wrap;">' . base64_decode($eval['note']) . '</pre>...

See the reference for more details 有关更多详细信息,请参见参考

Good luck, 祝好运,

bob 鲍勃

从不同的文本中获取文本<div id="text_translate"><p>我正在尝试获取每个&lt;tr&gt;的第一个&lt;td&gt;标记的值(文本),但我没有成功</p><p>在下面的示例中,我想要实现的是: juicy vic</p><p> 如何使用cheerio模块获取此值,从&lt;td&gt;标签获取这些值的最确定方法是什么?</p><pre> &lt;table class="partners"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Nome do Summoner&lt;/th&gt; &lt;th&gt;Posição&lt;/th&gt; &lt;th&gt;Tier&lt;/th&gt; &lt;th&gt;Campeão Recente&lt;/th&gt; &lt;th&gt;Chances&lt;/th&gt; &lt;th&gt;KDA&lt;/th&gt; &lt;th&gt;Nota&lt;/th&gt; &lt;th&gt;Registrado&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody id="partners"&gt; &lt;tr class="group" id="partner-86729" phx-click="delete" phx-target="1" data-phx-component="1"&gt; &lt;td&gt; &lt;a id="partner-86729-name" href="https://br.op.gg/summoner/userName=juicy vic?utm_source=duo.lol&amp;amp;utm_medium=partner-list&amp;amp;utm_campaign=permanent" target="_blank" phx-hook="StopPropagation" class="partner__profile partner__link"&gt; &lt;img src="//opgg-static.akamaized.net/images/profile_icons/profileIcon3542.jpg?image=q_auto:best&amp;amp;v=1518361200"&gt; juicy vic &lt;/a&gt; &lt;/td&gt; &lt;td id="partner-86729-edit-position" phx-hook="PartnerEditHook"&gt; &lt;span class="position-container"&gt; &lt;svg class="position-icon support" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path d="M13.991 8.327l2.248-2.036H24c-2.553 2.327-4.69 2.86-5.44 2.836h-1.45l2.03 2.91-3.553 1.527-1.596-5.237zM14.644 19.745L12.758 9.127l-.798.946V22l2.684-2.255zM10.009 8.327L7.76 6.291H0c2.553 2.327 4.69 2.86 5.44 2.836h1.45l-2.03 2.91 3.553 1.527 1.596-5.237zM9.277 19.745l1.886-10.618.797.946V22l-2.683-2.255zM9.048 2L8.25 3.382 11.876 7.6l3.627-4.218L14.56 2H9.048z"&gt;&lt;/path&gt; &lt;/svg&gt; &lt;span class="position-container__tooltip"&gt; Suporte &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;div class="flex-container"&gt; &lt;img src="/images/tiers/unranked-73687a6509dfb61e1f84b01150173ed0.png?vsn=d" class="partner__tier"&gt; Unranked &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div class="partner__champions"&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; 0승 0패 &lt;span class="dimmed"&gt; (&lt;span class="red"&gt;0%&lt;/span&gt;) &lt;/span&gt; &lt;/td&gt; &lt;td&gt; 3.1&lt;span class="separator"&gt;/&lt;/span&gt;5.5&lt;span class="separator"&gt;/&lt;/span&gt;21.4 &lt;span class="dimmed"&gt; (&lt;span class="green"&gt;4.45&lt;/span&gt;) &lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;div id="partner-86729-edit-note" phx-hook="PartnerEditHook" class="partner__note"&gt; alguem quer jogar normal game &lt;/div&gt; &lt;/td&gt; &lt;td class="partner__inserted" title="2021-05-19 12:33:38"&gt; 3 minutos atrás &lt;div class="opacity-25 group-hover:opacity-100 hover:text-red-600 transition-opacity" phx-click="report" phx-target="1"&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 inline-block" fill="none" viewBox="0 0 24 24" stroke="currentColor"&gt; &lt;path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"&gt;&lt;/path&gt; &lt;/svg&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;</pre><p> 我尝试了下面的代码,但没有成功:</p><pre> const $ = cheerio.load(html); $('body &gt; #partners &gt; tbody &gt; tr &gt; td').toArray().map(item =&gt; { console.log($(item).text()); });</pre></div><table></table> - Getting text from various <td> within a <table>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从不同的文本中获取文本<div id="text_translate"><p>我正在尝试获取每个&lt;tr&gt;的第一个&lt;td&gt;标记的值(文本),但我没有成功</p><p>在下面的示例中,我想要实现的是: juicy vic</p><p> 如何使用cheerio模块获取此值,从&lt;td&gt;标签获取这些值的最确定方法是什么?</p><pre> &lt;table class="partners"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Nome do Summoner&lt;/th&gt; &lt;th&gt;Posição&lt;/th&gt; &lt;th&gt;Tier&lt;/th&gt; &lt;th&gt;Campeão Recente&lt;/th&gt; &lt;th&gt;Chances&lt;/th&gt; &lt;th&gt;KDA&lt;/th&gt; &lt;th&gt;Nota&lt;/th&gt; &lt;th&gt;Registrado&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody id="partners"&gt; &lt;tr class="group" id="partner-86729" phx-click="delete" phx-target="1" data-phx-component="1"&gt; &lt;td&gt; &lt;a id="partner-86729-name" href="https://br.op.gg/summoner/userName=juicy vic?utm_source=duo.lol&amp;amp;utm_medium=partner-list&amp;amp;utm_campaign=permanent" target="_blank" phx-hook="StopPropagation" class="partner__profile partner__link"&gt; &lt;img src="//opgg-static.akamaized.net/images/profile_icons/profileIcon3542.jpg?image=q_auto:best&amp;amp;v=1518361200"&gt; juicy vic &lt;/a&gt; &lt;/td&gt; &lt;td id="partner-86729-edit-position" phx-hook="PartnerEditHook"&gt; &lt;span class="position-container"&gt; &lt;svg class="position-icon support" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path d="M13.991 8.327l2.248-2.036H24c-2.553 2.327-4.69 2.86-5.44 2.836h-1.45l2.03 2.91-3.553 1.527-1.596-5.237zM14.644 19.745L12.758 9.127l-.798.946V22l2.684-2.255zM10.009 8.327L7.76 6.291H0c2.553 2.327 4.69 2.86 5.44 2.836h1.45l-2.03 2.91 3.553 1.527 1.596-5.237zM9.277 19.745l1.886-10.618.797.946V22l-2.683-2.255zM9.048 2L8.25 3.382 11.876 7.6l3.627-4.218L14.56 2H9.048z"&gt;&lt;/path&gt; &lt;/svg&gt; &lt;span class="position-container__tooltip"&gt; Suporte &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;div class="flex-container"&gt; &lt;img src="/images/tiers/unranked-73687a6509dfb61e1f84b01150173ed0.png?vsn=d" class="partner__tier"&gt; Unranked &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div class="partner__champions"&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; 0승 0패 &lt;span class="dimmed"&gt; (&lt;span class="red"&gt;0%&lt;/span&gt;) &lt;/span&gt; &lt;/td&gt; &lt;td&gt; 3.1&lt;span class="separator"&gt;/&lt;/span&gt;5.5&lt;span class="separator"&gt;/&lt;/span&gt;21.4 &lt;span class="dimmed"&gt; (&lt;span class="green"&gt;4.45&lt;/span&gt;) &lt;/span&gt; &lt;/td&gt; &lt;td&gt; &lt;div id="partner-86729-edit-note" phx-hook="PartnerEditHook" class="partner__note"&gt; alguem quer jogar normal game &lt;/div&gt; &lt;/td&gt; &lt;td class="partner__inserted" title="2021-05-19 12:33:38"&gt; 3 minutos atrás &lt;div class="opacity-25 group-hover:opacity-100 hover:text-red-600 transition-opacity" phx-click="report" phx-target="1"&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 inline-block" fill="none" viewBox="0 0 24 24" stroke="currentColor"&gt; &lt;path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"&gt;&lt;/path&gt; &lt;/svg&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;</pre><p> 我尝试了下面的代码,但没有成功:</p><pre> const $ = cheerio.load(html); $('body &gt; #partners &gt; tbody &gt; tr &gt; td').toArray().map(item =&gt; { console.log($(item).text()); });</pre></div><table></table> - Getting text from various <td> within a <table> 在td的桌子里出去的大文本 - Large text going out of table in td's 设置表td中文本的最大宽度 - Set max-width of text within a table td 样式1 <td> 在一张桌子上有2 <td> 小号 - Style 1 <td> in a table with 2 <td>s 在容器内换行 - Wraping text inside a container 使用jQuery在表中删除和插入td - Removing and inserting td's within a table using jQuery 在具有特定id和tr具有特定属性的表中获取td中的文本 - get text in td's in a table with specific id and tr with specific attribute 如何能够在没有文本的情况下显示表TD - How to be able to show Table TD's without text in them 在表格中对齐“ td” - Align “td”s in a table td标签内的表格延伸td标签 - Table within td tag stretches td tag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM