2013-01-12 63 views
-1

我對CSS/html有點新。我試圖包含這個jquery插件使用tablesorter,基本上可以讓你的列排序。當按下表格的標題以按升序/降序對列進行排序時,它看起來會改變類別類型。我試圖按照這個教程:http://weblogs.asp.net/hajan/archive/2011/02/09/table-sorting-amp-pagination-with-jquery-in-asp-net-mvc.aspx爲特定列覆蓋<th>元素的CSS樣式

所以在我的一個專欄中,排序是沒有意義的,因爲它是完全相同的。我從一個asp.net/mvc3應用程序開始,我指的是最後一列,您可以點擊「詳細信息」。由於這不會改變,所以我想不在該列中有上/下箭頭。原來的CSS是這樣的:

table.tablesorter { 
    font-family:arial; 
    background-color: #CDCDCD; 
    margin:10px 0pt 15px; 
    font-size: 11pt; 
    width: 100%; 
    text-align: left; 
} 
table.tablesorter thead tr th, table.tablesorter tfoot tr th { 
    background-color: #e6EEEE; 
    border: 1px solid #FFF; 
    font-size: 10pt; 
    padding: 4px; 
} 
table.tablesorter thead tr .header { 
    background-image: url(themes/base/images/bg.gif); 
    background-repeat: no-repeat; 
    background-position: center right; 
    cursor: pointer; 
} 
table.tablesorter tbody td { 
    color: #3D3D3D; 
    padding: 4px; 
    background-color: #FFF; 
    vertical-align: top; 
} 
table.tablesorter tbody tr.odd td { 
    background-color:#F0F0F6; 
} 
table.tablesorter thead tr .headerSortUp { 
    background-image: url(themes/base/images/asc.gif); 
} 
table.tablesorter thead tr .headerSortDown { 
    background-image: url(themes/base/images/desc.gif); 
} 
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { 
    background-color: #8dbdd8; 
} 

所以我想我可以添加:

table.tablesorter thead .nostyle { 
    margin: 0; 
    padding: 0; 
    border: 0; 
    outline: 0; 
    font-size: 100%; 
    vertical-align: baseline; 
    background-color: #8dbdd8; 
} 

然後在標頭,我不想做的風格,這樣做:

  <th class="#nostyle"></th> 

但是,不起作用。我正確地處理這個問題嗎?或者,還有更好的方法?謝謝!

+0

o_O .......... ..'class =「#nostyle」'....'class =「nostyle」' – rlemon

回答

1

因爲你的班級不對。 #nostyle類別不匹配.nostyle。與class="nostyle"

<th class="nostyle"></th> 
0

如果您使用.nostyle匹配元素

table.tablesorter thead .nostyle 

你的類應該是爲前 'nostyle' 而不是 '#nostyle':

<th class="nostyle"></th> 
1

爲什麼不能簡單地禁用排序上那些專欄?

http://tablesorter.com/docs/#Configuration

外觀爲 '報頭' 設置:

頭對象的指令無效的對象在格式每列控制:標題:{0:{選項:設置},.. 。}例如,要禁用表的前兩列排序:標題:{0:{sorter:false},1:{sorter:false}}