CSS - Position Sticky in einer HTML Tabelle

Horizontal

Foo Bar Baz Foo Bar Baz Foo Bar Baz Foo Bar Baz Foo Bar Baz Foo Bar Baz
Fruitcake tiramisu sesame snaps toffee apple pie pastry caramels brownie. Tiramisu icing topping ice cream cupcake toffee fruitcake marzipan. Donut sweet roll jelly beans chocolate cake. Tootsie roll. Fruitcake tiramisu sesame snaps toffee apple pie pastry caramels brownie. Tiramisu icing topping ice cream cupcake toffee fruitcake marzipan. Donut sweet roll jelly beans chocolate cake. Tootsie roll. Fruitcake tiramisu sesame snaps toffee apple pie pastry caramels brownie. Tiramisu icing topping ice cream cupcake toffee fruitcake marzipan. Donut sweet roll jelly beans chocolate cake. Tootsie roll. Fruitcake tiramisu sesame snaps toffee apple pie pastry caramels brownie. Tiramisu icing topping ice cream cupcake toffee fruitcake marzipan. Donut sweet roll jelly beans chocolate cake. Tootsie roll. Fruitcake tiramisu sesame snaps toffee apple pie pastry caramels brownie. Tiramisu icing topping ice cream cupcake toffee fruitcake marzipan. Donut sweet roll jelly beans chocolate cake. Tootsie roll. Fruitcake tiramisu sesame snaps toffee apple pie pastry caramels brownie. Tiramisu icing topping ice cream cupcake toffee fruitcake marzipan. Donut sweet roll jelly beans chocolate cake. Tootsie roll.

<style>

div.table-wrapper {
 
overflow-xAuto;
}

th {
 
positionSticky;
 
top0;
}
</
style>

<
div class="table-wrapper">

<
table>
<
tr>
 <
th>Foo</th>
 <
th>Bar</th>
 <
th>Baz</th>
</
tr>
<
tr>
 <
td>-Inhalt-</td>
 <
td>-Inhalt-</td>
 <
td>-Inhalt-</td>
</
tr>
 </
table>

</
div>

Die "Zebrastreifen"     sind unter: Zebra-Tabelle mit CSS zu finden.

Vertikal

Um den Effekt zu sehen, Bitte nach unten scrollen!

Namen 1Namen 2Namen 3
Maria Makarius, Gregor, Otfried, Dietmar Genoveva, Odilo, Irma
Angelika, Christiane Emilia, Johann Raimund
Reinhold, Valentin Severin, Erhard, Gudula, Heiko Adrian, Julian, Alice
Paul, Leonie Thomas Ernst, Tatjana, Xenia
Jutta, Hilmar, Hilarius Rainer, Felix, Engelmar Arnold, Romedius, Mauro, Arno
Marcel, Tilman, Dietwald, Uli Anton, Rosalind Margitta, Ulfried, Uwe
Mario, Pia, Martha Fabian, Sebastian, Ursula Agnes, Meinrad, Ines
Vinzenz, Dietlinde, Jana Hartmut, Emerentia, Guido Franz, Vera, Thurid, Bernd
Pauli, Wolfram Timotheus, Titus, Paula Angela, Alrun, Gerd
Manfred, Thomas, Karl, Karolina Gerhard, Gerd, Josef Martina, Adelgunde
Johannes, Marcella, Rudbert Brigitta, Brigitte, Reginald, Barbara Bodo, Stephan
Blasius, Ansgar, Oskar, Michael Andreas, Veronika, Jenny Agatha, Albuin
Dorothea, Doris, Paul Richard, Ava, Ronan Elfrieda, Hieronymus, Philipp
Apollonia, Anne-Kathrin, Anna, Katharina Scholastika, Siegmar, Bruno Theodora, Theodor
Benedikt, Eulalia Christina, Irmhild, Adolf, Gisela Valentin, Cyrill, Method
Siegfried, Jovita, Georgia Juliana, Liane Alexis, Benignus
Constanze, Simon, Simone Irmgard, Irma, Hedwig Corona, Falko, Jacinta
Petrus, Gunhild, Enrica, Peter Petri Stuhlfeier, Isabella, Pit Romana, Raffaela
Matthias Walburga, Edeltraud Gerlinde, Ottokar, Edigna, Denis, Mechthild
Gabriel, Marko, Baldur Roman, Silvana, Oswald, Detlev Oswald
Albin, Roger, Leontina Volker, Agnes, Karl Kunigunde, Camilla, Leif, Friedrich
Kasimir, Edwin, Humbert Gerda, Olivia, Dietmar, Tim Fridolin, Nicola, Rosa, Nicole
Reinhard, Felicitas, Perpet, Volker Johannes, Gerhard Franziska, Bruno, Barbara, Dominik
Emil, Gustav Rosina, Alram, Ulrich Beatrix, Almut, Serafina
Judith, Pauline, Leander Mathilde, Eva, Evelyn Klemens, Louise
Herbert, Rüdiger Gertrud, Gertraud, Patrick Edward, Sibylle, Cyrill
Josef, Josefa, Josefine Claudia, Wolfram Christian, Axel, Emilia

<style>

th {
 
positionSticky;
 
top0;
}
</
style>

<
table>
<
tr>
 <
th>Foo</th>
 <
th>Bar</th>
 <
th>Baz</th>
</
tr>
<
tr>
 <
td>-Inhalt-</td>
 <
td>-Inhalt-</td>
 <
td>-Inhalt-</td>
</
tr>
 </
table>

Horizontal

1 apple pie cupcake caramels Donut Fruitcake Tiramisu toffee Fruitcake marzipan jelly beans chocolate Donut Tiramisu toffee cupcake Donut chocolate Fruitcake Fruitcake jelly beans marzipan Tiramisu Donut Tiramisu toffee cupcake chocolate Tiramisu Donut Fruitcake
2 caramels Tiramisu toffee Donut cupcake - Donut Fruitcake jelly beans marzipan chocolate Fruitcake toffee apple pie jelly beans marzipan apple pie Tootsie Donut apple pie cupcake caramels Donut Fruitcake Tiramisu

<style>
div.table-wrapper {
 overflow-xAuto;
}

div.table-wrapper th {
 positionSticky;
 left0;
 background#BFFF80;
}

div.table-wrapper td {
 white-spaceNowrap;
}
</style>

<div class="table-wrapper">

<table>
<tr>
 <th>1</th>
 <td>apple pie</td>
 <td>cupcake</td>
 <td>Tiramisu</td>
 <td>toffee</td>
 <td>... weitere Spalten!</td>
</tr>
<tr>
 <th>2</th>
 <td>caramels</td>
 <td>Tiramisu</td>
 <td>toffee</td>
 <td>marzipan</td>
 <td>... weitere Spalten!</td>
</tr>
 </table>

</div>

Vertikal

Namen 1Namen 2Namen 3Namen 4Namen 5
Maria Makarius, Gregor, Otfried, Dietmar Genoveva, Odilo, Irma Angelika, Christiane Emilia, Johann
Raimund Reinhold, Valentin Severin, Erhard, Gudula, Heiko Adrian, Julian, Alice Paul, Leonie
Thomas Ernst, Tatjana, Xenia Jutta, Hilmar, Hilarius Rainer, Felix, Engelmar Arnold, Romedius, Mauro, Arno
Marcel, Tilman, Dietwald, Uli Anton, Rosalind Margitta, Ulfried, Uwe Mario, Pia, Martha Fabian, Sebastian, Ursula
Agnes, Meinrad, Ines Vinzenz, Dietlinde, Jana Hartmut, Emerentia, Guido Franz, Vera, Thurid, Bernd Pauli, Wolfram
Timotheus, Titus, Paula Angela, Alrun, Gerd Manfred, Thomas, Karl, Karolina Gerhard, Gerd, Josef Martina, Adelgunde
Johannes, Marcella, Rudbert Brigitta, Brigitte, Reginald, Barbara Bodo, Stephan Blasius, Ansgar, Oskar, Michael Andreas, Veronika, Jenny
Agatha, Albuin Dorothea, Doris, Paul Richard, Ava, Ronan Elfrieda, Hieronymus, Philipp Apollonia, Anne-Kathrin, Anna, Katharina
Scholastika, Siegmar, Bruno Theodora, Theodor Benedikt, Eulalia Christina, Irmhild, Adolf, Gisela Valentin, Cyrill, Method
Siegfried, Jovita, Georgia Juliana, Liane Alexis, Benignus Constanze, Simon, Simone Irmgard, Irma, Hedwig
Corona, Falko, Jacinta Petrus, Gunhild, Enrica, Peter Petri Stuhlfeier, Isabella, Pit Romana, Raffaela Matthias
Walburga, Edeltraud Gerlinde, Ottokar, Edigna, Denis, Mechthild Gabriel, Marko, Baldur Roman, Silvana, Oswald, Detlev Oswald
Albin, Roger, Leontina Volker, Agnes, Karl Kunigunde, Camilla, Leif, Friedrich Kasimir, Edwin, Humbert Gerda, Olivia, Dietmar, Tim
Fridolin, Nicola, Rosa, Nicole Reinhard, Felicitas, Perpet, Volker Johannes, Gerhard Franziska, Bruno, Barbara, Dominik Emil, Gustav
Rosina, Alram, Ulrich Beatrix, Almut, Serafina Judith, Pauline, Leander Mathilde, Eva, Evelyn Klemens, Louise
Herbert, Rüdiger Gertrud, Gertraud, Patrick Edward, Sibylle, Cyrill Josef, Josefa, Josefine Claudia, Wolfram
Christian, Axel, Emilia
<style>
tr#tabellenkopf {
 position: Sticky;
 top: 0px;
}

tr#tabellenkopf > th:nth-child(even) {
 background-color: rgba(207, 231, 250, 0.9);
}

tr#tabellenkopf > th:nth-child(odd) {
 background-color: rgba(188, 221, 248, 0.9);
}
</style>

 <table>
 <tr id="tabellenkopf">
  <th>Namen 1</th>
  <th>Namen 2</th>
  <th>Namen 3</th>
 </tr>
 <tr>
...

Table-Head und Table-Foot festsetzen

Spalte A Spalte B Spalte C Spalte D Spalte E Spalte F Spalte G Spalte H Spalte I
23.02.2010 76745 83292 1016 88197 17861 78883 50736 52348
05.06.2012 6884 77556 19181 97348 7092 32802 52310 41172
29.02.1999 98285 52438 20608 97310 28703 80875 72625 72618
08.03.2017 76302 4123 95021 90748 55067 49553 67613 55350
22.02.1991 42312 31772 51550 83401 47719 58974 61174 70195
01.11.2008 37283 84064 37543 49387 71605 19950 7200 49423
22.11.2006 65536 11752 93848 69409 85603 4115 46704 52216
30.01.2015 96581 32015 67083 31729 95597 61987 82532 48583
07.05.2020 86189 62986 13897 83307 17077 78734 23761 75256
07.01.1998 33529 85979 91666 1139 17225 65556 58643 53846
02.09.2010 54998 65675 5471 47398 7272 78931 6092 95138
22.06.2014 46305 58699 87156 60612 94461 63307 53147 87134
24.07.2001 21736 97489 26275 21022 81508 83472 93877 78289
28.08.1990 30806 23129 45459 17999 11737 24088 10462 89120
18.02.1993 1722 76359 73768 55882 34691 21647 29166 80160
19.06.1991 94394 64834 26207 66162 77585 79032 31102 59213
12.11.2001 15215 29669 98908 27151 11681 27230 94937 82808
21.11.2011 31515 58535 2003 85644 91282 7745 8306 3908
29.09.2020 49722 69630 31651 97298 22002 59339 43819 3407
30.09.2004 1413 70543 45847 93482 95531 27118 63930 67830
05.03.2020 93088 336 76581 14939 93757 7728 28865 49731
28.06.2017 62017 16302 24239 12325 69933 24527 86226 21207
22.03.2009 66997 48115 28123 74733 18665 36888 87793 23193
05.11.1997 50987 41838 67717 23130 9710 41287 34772 54816
01.09.2010 52606 60449 74367 47803 54236 36787 94096 87664
A B C D E F G H I
<style>
table thead,
table tfoot {
  position: sticky;
}

table thead {
  inset-block-start: 0; /* "top" */
}

table tfoot {
  inset-block-end: 0; /* "bottom" */
}
</style>

Bausteine  Alle Anzeigen

Eine zufällige Auswahl von Bausteinen (Codeschnipsel) aus den Bereichen HTML, CSS, PHP, JavaScript und MySQL.

<label> Etikett

CSS - Pflichtfeld hervorheben

PHP - Zufällige Texte ausgeben

JavaScript - Fortschrittsanzeige mit JavaScript verändern

MySQL - Spalte auf UNIQUE setzen