HTML table row binnen thead verandert van breedte
De kolomkop (de tr binnen thead) schiet tegen mijn pagina header aan terwijl tekst in mijn tbody geleidelijk omhoog schuift. Ook de kolomkop wil ik graag geleidelijk omhoog laten schuiven.
Waar ik deze topic echter voor schrijf is dat de <tr> binnen <thead> van breedte verandert als deze tegen de pagina header aan schiet. Plak onderstaande code op je eigen webserver om dit te zien. Kopieer zelf even meerdere table rows binnen tbody. Ook de inhoud binnen <tbody> verschuift een beetje.
Ik heb ook al geprobeerd met border-spacing zonder succes.
Waar zit het hem in dat de breedte van de kolomkop (en tbody) verandert?
Al vast bedankt voor de suggesties.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content= "width=device-width, initial-scale=1.0">
<title>Fixed Header</title>
<style type="text/css">
.header_breed section {
position: fixed;
top: 0%;
padding: 12px;
left: .5%;
width: 100%;
height: 37px;
font-size: 30px;
background-color: blue;
}
.header_smal {
position: fixed;
top: 47px;
padding: 0;
left: .5%; right: 0;
width: 99.5%;
height: 25px;
font-size: 14px;
}
.header_smal li {
float: left;
}
#rechts_uitlijnen {
display: block;
padding: 1px;
float: right;
}
.sticky {
position: fixed;
top: 86px;
padding: 2px;
background-color: blue;
}
</style>
</head>
<body>
<div id = "rechts_uitlijnen" class = 'header_breed'><section> </section></div>
<ul class="header_smal" style="background-color : green;" >
<li id = "rechts_uitlijnen"><a href='<?php echo $url;?>index.php' style = 'color : black'>Inloggen</a></li>
</ul>
<script src="test2_script_header.js"></script>
<table align="center">
<tr height = 90> </tr>
<TR>
<TD>
<table Border = 0 align = "center">
<tr>
<td colspan = 3 align = 'right'> Aantal schapen 871 </td>
<td colspan = 2 style = 'font-size:13px';>   waarvan</td>
<td width ="150"><a href = '<?php echo $url;?>pdf.php' style = 'color : blue' > print pagina </a></td>
<td colspan = 2 ><a href="export.php"> Export-xlsx </a></td>
</tr>
<tr>
<td colspan = 2></td>
<td colspan = 2 style = 'font-size:13px';> 284 lammeren </td>
</tr>
<tr>
<td colspan = 2></td>
<td colspan = 2 style = 'font-size:13px';> 572 moeders </td>
</tr>
<tr>
<td colspan = 2></td>
<td colspan = 2 style = 'font-size:13px';> 15 vaders </td>
</tr>
</table>
<table Border = 0 align = "center">
<thead id="stickyHeader" style="background-color : green;">
<tr style = "font-size:12px;">
<th style = "text-align:center;"valign="bottom";width= 100>Transponder<br> bekend <hr></th>
<th style = "text-align:center;"valign="bottom";width= 100>Werknr <hr></th>
<th style = "text-align:center;"valign="bottom";width= 100>Levensnummer <hr></th>
<th style = "text-align:center;"valign="bottom";width= 100>Geboren <hr></th>
<th style = "text-align:center;"valign="bottom";width= 80>Geslacht <hr></th>
<th style = "text-align:center;"valign="bottom";width= 80>Generatie <hr></th>
<th style = "text-align:center;"valign="bottom";width= 50>Laatste<br> controle <hr></th>
<th width=60></th>
</tr>
</thead>
<tbody>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 00375 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481500375 <br> </td>
<td width = 100 style = "font-size:15px;"> 28-08-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ooi <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 03750 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481103750 <br> </td>
<td width = 100 style = "font-size:15px;"> 31-08-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ram <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 37566 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481102466 <br> </td>
<td width = 100 style = "font-size:15px;"> 24-12-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ram <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 37567 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481437567 <br> </td>
<td width = 100 style = "font-size:15px;"> 24-12-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ooi <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
</tbody>
</table>
<!-- Einde Aantal dieren -->
<script>
window.onscroll = function() {myFunction()};
var header = document.getElementById("stickyHeader");
var sticky = header.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
</script>
</body>
</TD>
</TR>
</table>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content= "width=device-width, initial-scale=1.0">
<title>Fixed Header</title>
<style type="text/css">
.header_breed section {
position: fixed;
top: 0%;
padding: 12px;
left: .5%;
width: 100%;
height: 37px;
font-size: 30px;
background-color: blue;
}
.header_smal {
position: fixed;
top: 47px;
padding: 0;
left: .5%; right: 0;
width: 99.5%;
height: 25px;
font-size: 14px;
}
.header_smal li {
float: left;
}
#rechts_uitlijnen {
display: block;
padding: 1px;
float: right;
}
.sticky {
position: fixed;
top: 86px;
padding: 2px;
background-color: blue;
}
</style>
</head>
<body>
<div id = "rechts_uitlijnen" class = 'header_breed'><section> </section></div>
<ul class="header_smal" style="background-color : green;" >
<li id = "rechts_uitlijnen"><a href='<?php echo $url;?>index.php' style = 'color : black'>Inloggen</a></li>
</ul>
<script src="test2_script_header.js"></script>
<table align="center">
<tr height = 90> </tr>
<TR>
<TD>
<table Border = 0 align = "center">
<tr>
<td colspan = 3 align = 'right'> Aantal schapen 871 </td>
<td colspan = 2 style = 'font-size:13px';>   waarvan</td>
<td width ="150"><a href = '<?php echo $url;?>pdf.php' style = 'color : blue' > print pagina </a></td>
<td colspan = 2 ><a href="export.php"> Export-xlsx </a></td>
</tr>
<tr>
<td colspan = 2></td>
<td colspan = 2 style = 'font-size:13px';> 284 lammeren </td>
</tr>
<tr>
<td colspan = 2></td>
<td colspan = 2 style = 'font-size:13px';> 572 moeders </td>
</tr>
<tr>
<td colspan = 2></td>
<td colspan = 2 style = 'font-size:13px';> 15 vaders </td>
</tr>
</table>
<table Border = 0 align = "center">
<thead id="stickyHeader" style="background-color : green;">
<tr style = "font-size:12px;">
<th style = "text-align:center;"valign="bottom";width= 100>Transponder<br> bekend <hr></th>
<th style = "text-align:center;"valign="bottom";width= 100>Werknr <hr></th>
<th style = "text-align:center;"valign="bottom";width= 100>Levensnummer <hr></th>
<th style = "text-align:center;"valign="bottom";width= 100>Geboren <hr></th>
<th style = "text-align:center;"valign="bottom";width= 80>Geslacht <hr></th>
<th style = "text-align:center;"valign="bottom";width= 80>Generatie <hr></th>
<th style = "text-align:center;"valign="bottom";width= 50>Laatste<br> controle <hr></th>
<th width=60></th>
</tr>
</thead>
<tbody>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 00375 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481500375 <br> </td>
<td width = 100 style = "font-size:15px;"> 28-08-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ooi <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 03750 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481103750 <br> </td>
<td width = 100 style = "font-size:15px;"> 31-08-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ram <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 37566 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481102466 <br> </td>
<td width = 100 style = "font-size:15px;"> 24-12-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ram <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
<tr align = "center">
<td width = 100 style = "font-size:13px;"> Ja <br> </td>
<td width = 100 style = "font-size:15px;"> 37567 <br> </td>
<td width = 100 style = "font-size:15px;"> 102481437567 <br> </td>
<td width = 100 style = "font-size:15px;"> 24-12-2023 <br> </td>
<td width = 100 style = "font-size:15px;"> ooi <br> </td>
<td width = 80 style = "font-size:15px;"> lam <br> </td>
<td width = 80 style = "font-size:15px;"> <br> </td>
<td width = 50> </td>
</tr>
</tbody>
</table>
<!-- Einde Aantal dieren -->
<script>
window.onscroll = function() {myFunction()};
var header = document.getElementById("stickyHeader");
var sticky = header.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
</script>
</body>
</TD>
</TR>
</table>
</html>
Gewijzigd op 08/01/2025 20:10:39 door Bas van de Ven