Fix Erste Spalte einer Bootstrap-Tabelle
Ich bin @ koala_devs Code in @ gefoldieser Beitra, um zu versuchen, die erste Spalte zu sperren. Der Code hat leider keine Auswirkung auf meinen Tisch. Ich habe mich gefragt, ob mir jemand einen Hinweis geben kann, was ich falsch gemacht habe, da ich neu in der Programmierung bin.
Das ist mein Tisch:http: //jsfiddle.net/mademoiselletse/bypbqboe/59
Dies ist der Code, den ich in JS (Zeile 121-133) eingefügt habe:
$(function() {
var $tableClass = $('.table');
// Make a clone of our table
var $fixedColumn = $tableClass.clone().insertBefore($tableClass).addClass('fixed-column');
// Remove everything except for first column
$fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();
// Match the height of the rows to that of the original table's
$fixedColumn.find('tr').each(function(i, elem) {
$(this).height($tableClass.find('tr:eq(' + i + ')').height());
});
});
Dies sind die CSS-Eigenschaften (Zeile 36-47), die ich eingefügt habe:
.table-responsive > .fixed-column {
position: absolute;
display: inline-block;
width: auto;
border-right: 1px solid #ddd;
}
@media(min-width:768px) {
.table-responsive>.fixed-column {
display: none;
}
}
Das einzige, was ich von der @ abgewichdemo code war das ich @ definiert ha$('.table')
wie$tableClass
Anstatt von$table
da ich vorher @ definiert havar $table
wie$('#table')
. Ihre Hilfe wird sehr geschätzt!