2012-05-16 33 views
0

我建立了一個表,它的行是像這樣CSS表得到錯誤的性質

<tr id="graphid+'" class="graphRow"> 
       <td colspan="2" style="width:5%; max-width:5%;"> 
        <div class="stockData"> 
         <div class="stockDatatable"> 
          <table class="stocktable"> 
           <tr><td id="stockDBnameid+'"></td></tr> 
           <tr><td class="Desctitle">תחום עיסוק:</td></tr> 
           <tr><td id="stockDBfieldid+'" class="stocktable"></td></tr> 
           <tr><td id="stockDBurlid+'" class="stocktable">כתובת אתר החברה</td></tr> 
           <tr><td class="Desctitle">ערך החברה:</td></tr> 
           <tr><td id="stockDBvalueid+'" class="stocktable">ערך החברה</td></tr> 
           <tr><td id="stockDBdescid+'" class="stocktable">תיאור המנייה</td></tr> 
          </table> 
         </div> 
        </div> 
       </td> 
       <td colspan="8"> 
        <table> 
         <tr> 
          <td> 
           <div id="graphDivid+'" class="GraphDiv"></div> 
          </td> 
         </tr> 
        </table> 
       </td> 
      </tr> 

,你可以看到,該行有兩個coloumns。 我在說第二個: 它是從div-> div-> table-> rows編譯的。 這些行從class = "graphRow"獲取它們的屬性,而不是從class ="stockTable"獲取它們的屬性。 該CSS是這樣的:

tr.graphRow td {background:lightgray;} 
tr.stocktable td {background:blue;} 

爲什麼不工作?

謝謝。

+0

我無法找到一個'帶班'stocktable' tr'元​​素,但你有一個表,這個類。 – Maehler

+0

你爲什麼要將'stockTable'應用到table和td標籤?根據你的風格定義,你應該將它應用到內部表格的tr標籤中。 –

+0

另外,請注意,您不會像在問題文本中那樣,在源代碼中隨意編寫「stockTable」。 –

回答

1

根據您的聲明tr.stocktable td{background:blue;},庫存僅適用於tr。但是你已經使用了<table>(​​)的庫存表。

申報stocktable像 -

.stocktable{background:blue;}

table.stocktable {background:blue;}

+0

明白了。謝謝! – devmonster