IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Mise en page CSS Discussion :

Rendre un tableau responsive avec breakpoints


Sujet :

Responsive design en CSS

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Femme Profil pro
    Chargé de référencement
    Inscrit en
    Mars 2018
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chargé de référencement
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2018
    Messages : 5
    Par défaut Rendre un tableau responsive avec breakpoints
    Bonjour,

    Je dois réaliser un tableau prix de plus de 12 colonnes. Trop grand lorsqu'on est sur mobile. J'ai appliqué le style responsive de bootstrap ce qui me donne une barre de défilement horizontale lorsque je réduis la page. Je souhaiterais que le tableau se divise en 2 ou en 3 parties pour ne pas obliger l'internaute à utilisé cette barre de défilement horizontale. bootstrap conseille d'utiliser des breakpoints avec ces balises.

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    <div class="table-responsive-sm">
      <table class="table">
        ...
      </table>
    </div>
     
    <div class="table-responsive-md">
      <table class="table">
        ...
      </table>
    </div>
     
    <div class="table-responsive-lg">
      <table class="table">
        ...
      </table>
    </div>
     
    <div class="table-responsive-xl">
      <table class="table">
        ...
      </table>
    </div>

    Je ne comprends pas comment procéder. Quelqu'un peut m'aider. svp? Voici mon tableau. D'avance merci!!

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    <table class="table table-striped table-bordered table-hover">
      <thead>
        <tr class="table-primary">
          <th scope="col">Nbre</th>
          <th scope="col"></th>
          <th colspan="2" scope="col">1</th>
          <th colspan="2" scope="col">de 2 à 5</th>
          <th colspan="2" scope="col">+ de 5</th>
           <th colspan="2" scope="col">+ de 10</th>
          <th colspan="2" scope="col">+ de 25</th>
          <th colspan="2" scope="col">+ de 50</th>
     
        </tr>
         <tr class="table-secondary">
          <th scope="col"></th>
          <th scope="col"></th>
          <th  scope="col">Express</th>
          <th  scope="col">+48h</th>
          <th scope="col">Express</th>
           <th  scope="col">+48h</th>
          <th  scope="col">Express</th>
          <th  scope="col">+48h</th>
          <th  scope="col">Express</th>
          <th  scope="col">+48h</th>
          <th scope="col">Express</th>
           <th  scope="col">+48h</th>
          <th  scope="col">Express</th>
          <th  scope="col">+48h</th>
     
        </tr>
      </thead>
      <tbody>
     
        <tr>
          <th class="table-primary" rowspan="3" scope="row">Pocket</th>
          <td>1 couleur</td>
          <td>8</td>
          <td>6</td>
          <td>7,5</td>
          <td>5,5</td>
          <td>7</td>
          <td>5</td>
          <td>6,5</td>
          <td>4,5</td>
          <td>6</td>
          <td>4</td>
          <td>5,5</td>
          <td>3,5</td>
        </tr>
     
        <tr>
       <td>2 couleurs</td>
           <td>9</td>
          <td>7</td>
          <td>8,5</td>
          <td>6,5</td>
          <td>8</td>
          <td>6</td>
          <td>7,5</td>
          <td>5,5</td>
          <td>7</td>
          <td>5</td>
          <td>6,5</td>
          <td>4,5</td>
        </tr>
     
        <tr>
          <td>3 couleurs</td>
          <td>10</td>
          <td>8</td>
          <td>9,5</td>
          <td>7,5</td>
          <td>9</td>
          <td>7</td>
          <td>8,5</td>
          <td>6,5</td>
          <td>8</td>
          <td>6</td>
          <td>7,5</td>
          <td>5,5</td>
        </tr>
     
         <tr>
          <th class="table-primary" rowspan="3" scope="row">A5</th>
          <td>1 couleur</td>
          <td>11</td>
          <td>9</td>
          <td>10,5</td>
          <td>8,5</td>
          <td>10</td>
          <td>8</td>
          <td>9,5</td>
          <td>7,5</td>
          <td>9</td>
          <td>7</td>
          <td>8,5</td>
          <td>6,5</td>
        </tr>
         <tr>
     
          <td>2 couleurs</td>
           <td>12</td>
          <td>10</td>
          <td>11,5</td>
          <td>9,5</td>
          <td>11</td>
          <td>9</td>
          <td>10,5</td>
          <td>8,5</td>
          <td>10</td>
          <td>8</td>
          <td>9,5</td>
          <td>7,5</td>
        </tr>
         <tr>
     
          <td>3 couleurs</td>
           <td>13</td>
          <td>11</td>
          <td>12,5</td>
          <td>10,5</td>
          <td>12</td>
          <td>10</td>
          <td>11,5</td>
          <td>9,5</td>
          <td>11</td>
          <td>9</td>
          <td>10,5</td>
          <td>8,5</td>
        </tr>
         <tr>
          <th class="table-primary" rowspan="3" scope="row">A4</th>
          <td>1 couleur</td>
          <td>14</td>
          <td>12</td>
          <td>13,5</td>
          <td>11,5</td>
          <td>13</td>
          <td>11</td>
          <td>12,5</td>
          <td>10,5</td>
          <td>12</td>
          <td>10</td>
          <td>11,5</td>
          <td>9,5</td>
        </tr>
         <tr>
     
          <td>2 couleurs</td>
           <td>15</td>
          <td>13</td>
          <td>14,5</td>
          <td>12,5</td>
          <td>14</td>
          <td>12</td>
          <td>13,5</td>
          <td>11,5</td>
          <td>13</td>
          <td>11</td>
          <td>12,5</td>
          <td>10,5</td>
        </tr>
         <tr>
     
          <td>3 couleurs</td>
           <td>16</td>
          <td>14</td>
          <td>15,5</td>
          <td>13,5</td>
          <td>15</td>
          <td>13</td>
          <td>14,5</td>
          <td>12,5</td>
          <td>14</td>
          <td>12</td>
          <td>13,5</td>
          <td>11,5</td>
        </tr>
         <tr>
          <th class="table-primary" rowspan="3" scope="row">A3</th>
          <td>1 couleur</td>
          <td>17</td>
          <td>15</td>
          <td>16,5</td>
          <td>14,5</td>
          <td>16</td>
          <td>14</td>
          <td>15,5</td>
          <td>13,5</td>
          <td>15</td>
          <td>13</td>
          <td>14,5</td>
          <td>12,5</td>
        </tr>
         <tr>
     
          <td>2 couleurs</td>
          <td>18</td>
          <td>16</td>
          <td>17,5</td>
          <td>15,5</td>
          <td>17</td>
          <td>15</td>
          <td>16,5</td>
          <td>14,5</td>
          <td>16</td>
          <td>14</td>
          <td>15,5</td>
          <td>13,5</td>
        </tr>
         <tr>
     
          <td>3 couleurs</td>
          <td>19</td>
          <td>17</td>
          <td>18,5</td>
          <td>16,5</td>
          <td>18</td>
          <td>16</td>
          <td>17,5</td>
          <td>15,5</td>
          <td>17</td>
          <td>15</td>
          <td>16,5</td>
          <td>14,5</td>
        </tr>
      </tbody>
    </table>

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    1-
    que le tableau se divise en 2 ou en 3 parties...
    selon quelques critères : 2 x 6 colonnes ? 3 x 4 colonnes ?
    Je doute qu'on puisse le faire en CSS !
    En JS, sûrement.

    2-
    ...pour ne pas obliger l'internaute à utilisé cette barre de défilement horizontale...
    Sur mobile, généralement, ce sont des écrans tactiles : on peut faire glisser le tableau avec le doigt (sans être obligé de toucher la barre de défilement)

    3- Autre solution -> faire 2 tableaux dès le départ : un pour "Express" et l'autre pour "+48h" !
    Problème réglé !
    Dernière modification par Invité ; 21/03/2018 à 15h49.

  3. #3
    Nouveau membre du Club
    Femme Profil pro
    Chargé de référencement
    Inscrit en
    Mars 2018
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chargé de référencement
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2018
    Messages : 5
    Par défaut
    Haaaa Bonne idée

    Sinon je pensais en 3 comme ceci, c'est jouable? :
    Nom : Capture d'écran 2018-03-21 15.56.45.png
Affichages : 1504
Taille : 34,1 Ko
    Nom : 2.png
Affichages : 1015
Taille : 33,9 Ko
    Nom : 3.png
Affichages : 1005
Taille : 40,6 Ko

    Sur le site bootstrap :https://getbootstrap.com/docs/4.0/content/tables/ Quand on diminue la page, les tableaux se réduisent. Ils sont bootstraap. Chez moi avec le même code, il ajoute une barre de défilement. Si ça rétrécissait ce serait déjà bien!

  4. #4
    Invité
    Invité(e)
    Par défaut
    1- On voit bien qu'une fois séparé en trois, le tableau est difficile à lire (on a du mal à s'y retrouver)...
    En plus, ça va demander du JavaScript pour dupliquer les 1ères colonnes d'une table à l'autre.
    Bfrf : fastidieux pour un résultat médiocre.

    2- Séparer dès le départ en deux tableaux "Express" et "+48h" me semble plus judicieux (et surtout plus facile à coder !)
    Il est alors relativement facile de comparer les valeurs dans chaque tableau.

    3-OU garder UN SEUL tableau, mais n'afficher qu'un des 2 tarifs : "Express" OU "+48h" * **
    On utilise alors deux boutons radio * (ou liste déroulante), pour afficher/masquer (au clic) un tableau sur deux (et n'en avoir toujours qu'un visible à l'écran).

    * C'est ce qui se fait sur de nombreux sites pour afficher/masquer les prix soit en HT, soit en TTC ! (un exemple ici **)

    ** La technique consiste ici, dans la même cellule du même tableau, à afficher/masquer via JavaScript un span ou l'autre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <span class="price-excluding-tax" style="display: none;">...</span>
    <span class="price-including-tax" style="display: block;">...</span>
    Dernière modification par Invité ; 21/03/2018 à 18h15.

  5. #5
    Nouveau membre du Club
    Femme Profil pro
    Chargé de référencement
    Inscrit en
    Mars 2018
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chargé de référencement
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Mars 2018
    Messages : 5
    Par défaut
    Bonne idée je vais faire comme ca! Merci beaucoup pour ton temps.

  6. #6
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 211
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 211
    Par défaut
    Bonjour,
    j'aurais bien vu un système d'onglet.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [CSS 3] Rendre un tableau responsive - Media queries
    Par Lizzon dans le forum Mise en page CSS
    Réponses: 13
    Dernier message: 04/07/2016, 12h06
  2. Rendre un tableau html responsive
    Par MInfo25 dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 04/01/2016, 12h53
  3. [Tableaux] Trier un tableau comme avec ORDER BY DESC
    Par Anduriel dans le forum Langage
    Réponses: 28
    Dernier message: 08/12/2005, 18h50
  4. [Tableau]Problèmes avec copie de tableau
    Par Itachi-san dans le forum Collection et Stream
    Réponses: 13
    Dernier message: 25/11/2005, 17h23
  5. [VB6] recuperer des valeurs ds un tableau html avec vb!!
    Par leo13 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 11/12/2004, 13h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo