Rowspan 不使用頂行 (Rowspan not using top row)


問題描述

Rowspan 不使用頂行 (Rowspan not using top row)

我不明白為什麼我的列不會跨越我創建的頂行和底行。它應該看起來像“今天”列的頂部和底部比其他列高。

代碼很多,我不確定應該在不變形的情況下剪切什麼或添加一個新變量(它需要一個流體高度)。JSFiddle:http://jsfiddle.net/DaAwesomeP/aU9Le/

基本 HTML 佈局:

<table id="weatherForecast">
  <tr class="weatherForecast‑row‑outer">
    <td></td>
  </tr>
  <tr id="weatherForecast‑row">
    <td id="weatherForecast‑DATE" class="weatherForecast‑day  weatherForecast‑day‑today" rowspan="3">
    <!‑‑ Cell Content for "Today" Here ‑‑>
      <td id="weatherForecast‑DATE" class="weatherForecast‑day ">
      <!‑‑ Cell Content Here ‑‑>
      </td>
    </tr>
    <tr class="weatherForecast‑row‑outer">
      <td></td>
    </tr>
</table>

這是一張顯示我想要的圖片:


參考解法

方法 1:

The table markup violates the HTML table model rules, as the W3C HTML Validator tells you if you use it in HTML5 mode.

Since there are two cells on the second row, the first row should occupy two columns, too, so set colspan=2 on its td element.

And you cannot use rowspan=3, since there aren’t just enough rows in the table to span. Use rowspan=2 instead.

It’s difficult to tell what you actually want (a drawing would have helped), but the following would at least be valid HTML (note that I fixed a problem with duplicate id values too):

<table id="weatherForecast" border>
  <tr class="weatherForecast‑row‑outer">
    <td colspan=2></td>
  </tr>
  <tr id="weatherForecast‑row">
    <td id="weatherForecast‑DATE" class="weatherForecast‑day weatherForecast‑day‑today" rowspan="2">
    <!‑‑ Cell Content for "Today" Here ‑‑>
      <td id="weatherForecast‑DATE2" class="weatherForecast‑day ">
      <!‑‑ Cell Content Here ‑‑>
      </td>
    </tr>
    <tr class="weatherForecast‑row‑outer">
      <td></td>
    </tr>

方法 2:

I got rid of the all of the rowspan and just gave one cell display: block. I can then adjust the height of that cell specifically without changing the others. I used calc to provide a variable height.

(by DaAwesomePJukka K. KorpelaDaAwesomeP)

參考文件

  1. Rowspan not using top row (CC BY‑SA 3.0/4.0)

#row #css #html #html-table






相關問題

PHP Grid 類型 Array 獲取行或列 (PHP Grid type Array get row or column)

在 Twitter 引導程序中為行添加背景顏色和填充 (Adding background color and padding to row in Twitter bootstrap)

從 GROUP BY 組中選擇具有特定內容的行 (Select a row with specific content from a GROUP BY group)

How to delete a row in Sqlite database in Android application by user at listview (How to delete a row in Sqlite database in Android application by user at listview)

mysql fetch 中的 $row 是什麼類型的變量? (What kind of variable is $row from a mysql fetch?)

Rowspan 不使用頂行 (Rowspan not using top row)

包含相同圖像的一半相等部分的行與 HTML 重疊 (Row with half equal section containing same image overlapped HTML)

使用 Oracle 10 監視哪些語句更新(以及何時)某個表行 (Monitoring which statement updates (and when) a certain table row with Oracle 10)

在表格行上調用 Dibs (Calling Dibs on a table row)

從表格視圖單元格添加視圖 (Add view from table view cell)

如何將引導程序 4 中的內容連續居中? (How to center in bootstrap 4 the content in a row?)

是否有更快的方法來檢查數據條目的符號是否與給定熊貓列的前一行中數據條目的符號不同? (Is there a faster way to check if the sign of the data entry is different than the sign of the data entry in previous row for a given pandas column?)







留言討論