[英]How to create a tab in the text inside of the <tr> </tr>
<tr> <td>Where to go if sick? 3 minuts ago</td> </tr>
I am trying building the website but I am not sure how I can make a space between "sick" and "3minutes ago".我正在尝试建立网站,但我不确定如何在“生病”和“3 分钟前”之间留出空间。 I found out
我发现
is a tab in HTML but I am pretty sure there is a simpler way to do this.是 HTML 中的一个选项卡,但我很确定有一种更简单的方法可以做到这一点。 Can anyone tell me how to do it?
谁能告诉我怎么做?
Set a width on your td
element, then give it display: flex
and justify-content: space-between
.在你的
td
元素上设置一个宽度,然后给它display: flex
和justify-content: space-between
。
td { display: flex; width: 400px; justify-content: space-between; }
<table> <tr> <td> <span>Where to go if sick?</span> <span>"3 minutes ago"</span> </td> </tr> </table>
Flexbox is a great tool to let the browser decide how things should be laid out, instead of giving explicit values to everything. Flexbox 是一个很棒的工具,可以让浏览器决定事物的布局方式,而不是为所有事物提供明确的值。 See the MDN docs on flexbox .
请参阅flexbox上的 MDN 文档。
The reason I added span
to each text snippet is so that there are 2 discrete child elements of the td
so flexbox knows which elements to put space-between
.我为每个文本片段添加
span
的原因是td
有 2 个离散的子元素,因此 flexbox 知道在哪些元素space-between
放置space-between
。
Does it have to be a table?它必须是一张桌子吗? If so, you can use padding:
如果是这样,您可以使用填充:
<table style="border-collapse: collapse">
<tr>
<td style="padding-right: 25px">
Where to go if sick?
</td>
<td>
"3 minuts ago"
</td>
</tr>
</table>
Also you can add child elements into td and set margin:您也可以将子元素添加到 td 并设置边距:
<tr>
<td>
<span style="margin-right: 25px">Where to go if sick?</span>
<span>"3 minuts ago"</span>
</td>
</tr>
If you don't need a table.如果你不需要桌子。 Just add margin-right:
只需添加边距:
<p><span style="margin-right: 25px">Where to go if sick?</span> "3 minuts ago"</p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.