新线路上的最后一个 td?

发布于 2024-12-11 03:29:23 字数 1539 浏览 0 评论 0原文

我为客户从word转换了一些表格数据:

<table>
  <tr>
    <th><p>SPAGHETTI &ndash; Deeg voorgerechten</p></th>
  </tr>
  <tr>
    <td>SPAGHETTI AL PESCATORE</td>
    <td>&euro;11.50</td>
    <td><p  >Zeevruchten in speciale tomatensaus</p></td>
  </tr>
  <tr>
    <td>SPAGHETTI ALLA MATRICIANA</td>
    <td>&euro;9.25</td>
    <td><p  >Met spek, knoflook in tomatensaus</p></td>
  </tr>
  <tr>
    <td>SPAGHETTI BOSCAIOLA</td>
    <td>&euro;10.25
      </td>
    <td><p  >Met ham, spek, knoflook in roomsaus</p></td>
  </tr>
<table>

这是表格数据。它应该在表格中:)

在单词 doc 中,他将最后一个单元格(荷兰语描述)放在新行上。我可以使用 colspan="2" 将每个最后一个单元格正则表达式到新行,但这不是结构。我尝试过:

td:last-child {
  display: block;
}

但每个浏览器都会忽略这一点。有什么想法吗?

编辑:听起来有点模糊,不是吗?

我有:

cell 1.1                     cell 1.2                               cell 1.3
cell 2.1                     cell 2.2                               cell 2.3
cell 3.1                     cell 3.2                               cell 3.3

我想要:

cell 1.1                     cell 1.2                      
cell 1.3
cell 2.1                     cell 2.2                        
cell 2.3
cell 3.1                     cell 3.2                       
cell 3.3

I converted some tabular data from word for a client:

<table>
  <tr>
    <th><p>SPAGHETTI – Deeg voorgerechten</p></th>
  </tr>
  <tr>
    <td>SPAGHETTI AL PESCATORE</td>
    <td>€11.50</td>
    <td><p  >Zeevruchten in speciale tomatensaus</p></td>
  </tr>
  <tr>
    <td>SPAGHETTI ALLA MATRICIANA</td>
    <td>€9.25</td>
    <td><p  >Met spek, knoflook in tomatensaus</p></td>
  </tr>
  <tr>
    <td>SPAGHETTI BOSCAIOLA</td>
    <td>€10.25
      </td>
    <td><p  >Met ham, spek, knoflook in roomsaus</p></td>
  </tr>
<table>

It's tabular data. It should be in a table :)

In the word doc, he put the last cell (the Dutch description) on a new line. I could regex every last cell to a new row with colspan="2", but that's not the structure. I tried:

td:last-child {
  display: block;
}

But every browser ignores that. Any ideas?

EDIT: It sounds a little bit vague, doesn't it?

I have:

cell 1.1                     cell 1.2                               cell 1.3
cell 2.1                     cell 2.2                               cell 2.3
cell 3.1                     cell 3.2                               cell 3.3

I want:

cell 1.1                     cell 1.2                      
cell 1.3
cell 2.1                     cell 2.2                        
cell 2.3
cell 3.1                     cell 3.2                       
cell 3.3

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

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

发布评论

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

评论(3

メ斷腸人バ 2024-12-18 03:29:23

桌子不是这样工作的。 表示新行, 位于同一行。您永远不会(或至少不应该拥有)来自不同行的同一

cell 1.1                     cell 1.2                      
cell 2.1
cell 3.1                     cell 3.2                        
cell 4.1
cell 5.1                     cell 5.2                       
cell 6.3

编辑:
似乎您出于某种原因在不适合使用表格的情况下沉迷于使用表格。我可以建议以下实现(未经测试,您应该了解我正在尝试做的事情的基础知识)吗?

.menu-item: {
  display: block;
}

.price: {
  float: right;
}

.description {
  clear: both;
}
<h3>Spaghetti</h3>
<div class="menu-item">
  <strong>Food name</strong>
  <span class="price">10.00</span>
  <span class="description">A great dish</span>
</div>

<div class="menu-item">
  <strong>Food name</strong>
  <span class="price">10.00</span>
  <span class="description">A great dish</span>
</div>

<div class="menu-item">
  <strong>Food name</strong>
  <span class="price">10.00</span>
  <span class="description">A great dish</span>
</div>

Tables don't work like that. <tr> signifies a new row, a <td> is on the same row. You'll never have (or at least should never have) <td>'s from the same <tr> on different lines.

cell 1.1                     cell 1.2                      
cell 2.1
cell 3.1                     cell 3.2                        
cell 4.1
cell 5.1                     cell 5.2                       
cell 6.3

Edit:
It seems like you're hung up on using tables for some reason in a situation that is not suited for tables. May I suggest the following implementation (untested, you should get the basics of what I'm trying to do)?

.menu-item: {
  display: block;
}

.price: {
  float: right;
}

.description {
  clear: both;
}
<h3>Spaghetti</h3>
<div class="menu-item">
  <strong>Food name</strong>
  <span class="price">10.00</span>
  <span class="description">A great dish</span>
</div>

<div class="menu-item">
  <strong>Food name</strong>
  <span class="price">10.00</span>
  <span class="description">A great dish</span>
</div>

<div class="menu-item">
  <strong>Food name</strong>
  <span class="price">10.00</span>
  <span class="description">A great dish</span>
</div>

烏雲後面有陽光 2024-12-18 03:29:23

试试这个小提琴:

https://jsfiddle.net/r47bm836/

table tr, table tr td:nth-last-child(1) {
    display: block !important;
    clear: both;
}
table tr, table tr td {
    clear: both;
}

似乎对我有用。

我有同样的问题。

try this fiddle:

https://jsfiddle.net/r47bm836/

table tr, table tr td:nth-last-child(1) {
    display: block !important;
    clear: both;
}
table tr, table tr td {
    clear: both;
}

seems to work for me.

I had same problem.

山色无中 2024-12-18 03:29:23

使用单个 将单元格 1.3、2.3 和 3.3 设为新的

Make cell 1.3, 2.3, and 3.3 a new <tr> with a single <td colspan="2">.

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