IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Téléchargé 7 fois
Vote des utilisateurs
1 
0 
Détails
Licence : Non renseignée
Mise en ligne le 15 octobre 2013
Plate-forme : Windows
Langue : Français
Référencé dans
Navigation

Tableau avec entête et pied fixe

Tableau avec entête et pied fixe et scroll sur les données.
Avatar de Pelote2012
Membre chevronné https://www.developpez.com
Le 16/10/2013 à 11:19
Voici une version plus simple et plus classique. toutes les colonnes sont visibles (pas de scroll vertical).

De plus j'ai centralisé la largeur totale.
Code html : Sélectionner tout
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<head id="Head1" runat="server"> 
    <title></title> 
    <script src="/script/jquery-1.9.0.js" type="text/javascript"></script> 
    <style type="text/css"> 
        .HauteurLigne 
        { 
            height: 50px; 
        } 
         
        table 
        { 
            border-collapse: collapse; 
        } 
         
        td 
        { 
            border: 1px solid; 
        } 
        
        .general 
        { 
            position: absolute; 
            overflow: hidden; 
            height: 250px; 
            border: 1px solid; 
        } 
         
        .entete 
        { 
            position: absolute; 
            left: 0px; 
            top: 0px; 
            position: absolute; 
            background-color: #99CCCC; 
        } 
         
        .Cellule 
        { 
            width: 100px; 
        } 
         
        .pied 
        { 
            position: absolute; 
            left: 0px; 
            bottom: 0px; 
            background-color: #99CCCC; 
        } 
         
        .donnees 
        { 
            position: absolute; 
            overflow: scroll; 
            overflow-x: hidden; 
            left: 0px; 
            top: 50px; 
            height: 150px; 
            background-color: #9999CC; 
        } 
    </style> 
    <script type="text/javascript"> 
        $(function () { 
  
            var LargTot = 400; 
            $("#gene").css("width", LargTot + "px"); 
            $("#datas").css("width", LargTot + "px"); 
            $("#Foot").css("width", LargTot + "px"); 
            $("#tete").css("width", LargTot + "px");  
  
            /*Elargir pour mettre scroll vertical en dehors du tableau*/ 
            var hsb = getScrollBarWidth(); 
            $("#gene").css("padding-right", hsb + "px"); 
            $("#datas").css("padding-right", hsb + "px"); 
  
            $("#tbdatas").css("width", LargTot + "px"); 
        }); 
  
        function getScrollBarWidth() { 
            var width = 100, $outer = $('<div>').css({ visibility: 'hidden', width: width, overflow: 'scroll' }).appendTo('body'), widthWithScroll = $('<div>').css({ width: '100%' }).appendTo($outer).outerWidth(); 
            $outer.remove(); 
            return width - widthWithScroll; 
        }; 
  
    </script> 
</head> 
<body> 
    <div class="general" id="gene"> 
        <div class="entete" id="tete"> 
            <table> 
                <tr class="HauteurLigne"> 
                    <td class="Cellule"> 
                        Alpha 
                    </td> 
                    <td class="Cellule"> 
                        Beta 
                    </td> 
                    <td class="Cellule"> 
                        Gamma 
                    </td> 
                    <td class="Cellule"> 
                        Omega 
                    </td> 
                </tr> 
            </table> 
        </div> 
        <div class="donnees" id="datas"> 
            <table id="tbdatas"> 
                <tr class="HauteurLigne"> 
                    <td class="Cellule"> 
                        1 
                    </td> 
                    <td class="Cellule"> 
                        2 
                    </td> 
                    <td class="Cellule"> 
                        3 
                    </td> 
                    <td class="Cellule"> 
                        4 
                    </td> 
                </tr> 
                <tr class="HauteurLigne"> 
                    <td class="Cellule"> 
                        1 
                    </td> 
                    <td class="Cellule"> 
                        2 
                    </td> 
                    <td class="Cellule"> 
                        3 
                    </td> 
                    <td class="Cellule"> 
                        4 
                    </td> 
                </tr> 
                <tr class="HauteurLigne"> 
                    <td class="Cellule"> 
                        1 
                    </td> 
                    <td class="Cellule"> 
                        2 
                    </td> 
                    <td class="Cellule"> 
                        3 
                    </td> 
                    <td class="Cellule"> 
                        4 
                    </td> 
                </tr> 
                <tr class="HauteurLigne"> 
                    <td class="Cellule"> 
                        1 
                    </td> 
                    <td class="Cellule"> 
                        2 
                    </td> 
                    <td class="Cellule"> 
                        3 
                    </td> 
                    <td class="Cellule"> 
                        4 
                    </td> 
                </tr> 
            </table> 
        </div> 
        <div class="pied" id="Foot"> 
            <table> 
                <tr class="HauteurLigne"> 
                    <td class="Cellule"> 
                        a 
                    </td> 
                    <td class="Cellule"> 
                        b 
                    </td> 
                    <td class="Cellule"> 
                        g 
                    </td> 
                    <td class="Cellule"> 
                        o 
                    </td> 
                </tr> 
            </table> 
        </div> 
    </div> 
</body>
Avatar de Pelote2012
Membre chevronné https://www.developpez.com
Le 16/10/2013 à 14:51
Et voici la version qui s'agrandi jusqu'à une hauteur
De plus la hauteur d'entete et de pied n'est plus forcée
Code html : Sélectionner tout
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
<head id="Head1" runat="server"> 
    <title></title> 
    <script src="/script/jquery-1.9.0.js" type="text/javascript"></script> 
    <style type="text/css"> 
         table 
        { 
            border-collapse: collapse; 
        } 
         
        td 
        { 
            border: 1px solid; 
        } 
         
        .general 
        { 
            position: absolute; 
            overflow: hidden; 
            border: 1px solid; 
        } 
         
        .entete 
        { 
            position: absolute; 
            left: 0px; 
            top: 0px; 
            position: absolute; 
            background-color: #99CCCC; 
        } 
         
        .Cellule 
        { 
            width: 100px; 
        } 
         
        .pied 
        { 
            position: absolute; 
            left: 0px; 
            bottom: 0px; 
            background-color: #99CCCC; 
        } 
         
        .donnees 
        { 
            position: absolute; 
            overflow: hidden; 
            left: 0px; 
            background-color: #9999CC; 
        } 
    </style> 
    <script type="text/javascript"> 
        $(function () { 
  
            var hsb = getScrollBarWidth(); 
            var HautTot = 250; 
            $("#datas").css("max-height", HautTot - parseInt($("#tete").css('height')) - parseInt($("#Foot").css('height')) + "px"); 
  
            /*Largeur totale du tableau*/ 
            var LargTot = 400; 
            $("#gene").css("width", LargTot + "px"); 
            $("#tete").css("width", LargTot + "px"); 
            $("#datas").css("width", LargTot + "px"); 
            $("#Foot").css("width", LargTot + "px"); 
  
            /*Hauteur globale de départ*/ 
            $("#gene").css("height", parseInt($("#tete").css('height')) + parseInt($("#Foot").css('height')) + "px"); 
  
            /*Positionner les datas*/ 
            $("#datas").css("top", parseInt($("#tete").css('height')) + "px"); 
  
            $("#tbdatas").css("width", LargTot + "px"); 
  
            $("#btnAdd").click(function () { 
                var HL = 50; 
                var row = '<tr height=' + HL + '><td class="Cellule">1</td><td class="Cellule">2</td><td class="Cellule">3</td><td class="Cellule">4</td></tr>'; 
                $('#tbdatas').append(row); 
  
                var Siz = parseInt($("#gene").css('height')); 
                if (Siz + HL < HautTot) { 
                    $("#gene").css("height", Siz + HL + "px"); 
                } 
                else { 
                    /*Elargir pour mettre scroll vertical en dehors du tableau*/ 
                    if (parseInt($("#gene").css('padding-right'))!=hsb) { 
                        $("#gene").css("padding-right", hsb + "px"); 
                        $("#datas").css("padding-right", hsb + "px"); 
                        $("#datas").css("overflow", "scroll"); 
                        $("#datas").css("overflow-x",  "hidden"); 
                    } 
                } 
            }); 
  
        }); 
  
        function getScrollBarWidth() { 
            var width = 100, $outer = $('<div>').css({ visibility: 'hidden', width: width, overflow: 'scroll' }).appendTo('body'), widthWithScroll = $('<div>').css({ width: '100%' }).appendTo($outer).outerWidth(); 
            $outer.remove(); 
            return width - widthWithScroll; 
        }; 
  
    </script> 
</head> 
<body> 
    <button id="btnAdd"> 
        Ajouter 1 ligne</button> 
    <div class="general" id="gene"> 
        <div class="entete" id="tete"> 
            <table> 
                <tr> 
                    <td class="Cellule"> 
                        Alpha 
                    </td> 
                    <td class="Cellule"> 
                        Beta 
                    </td> 
                    <td class="Cellule"> 
                        Gamma 
                    </td> 
                    <td class="Cellule"> 
                        Omega 
                    </td> 
                </tr> 
            </table> 
        </div> 
        <div class="donnees" id="datas"> 
            <table id="tbdatas"> 
            </table> 
        </div> 
        <div class="pied" id="Foot"> 
            <table> 
                <tr> 
                    <td class="Cellule"> 
                        a 
                    </td> 
                    <td class="Cellule"> 
                        b 
                    </td> 
                    <td class="Cellule"> 
                        g 
                    </td> 
                    <td class="Cellule"> 
                        o 
                    </td> 
                </tr> 
            </table> 
        </div> 
    </div> 
</body>
Developpez.com décline toute responsabilité quant à l'utilisation des différents éléments téléchargés.