Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1319 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  CSS 3 bonne utilisation du not pour usage adaptatif

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

CSS 3 bonne utilisation du not pour usage adaptatif

n°2216253
Aurelienaz​erty
Posté le 15-01-2014 à 21:28:57  profilanswer
 

Bonjour,
 
Je cherche à faire une version mobile adaptative pour mon site et se pose la question des tableaux, dans certains (90%) cas je souhaites qu'ils soient adaptatifs le reste (10%) non.
 
J'ai utilisé la CSS3 suivante :

Code :
  1. @media
  2. only screen and (max-width: 760px),
  3. (min-device-width: 768px) and (max-device-width: 1024px)  {
  4. /* Force table to not be like tables anymore */
  5. table:not(.forTable), thead:not(.forTable), tbody:not(.forTable), th:not(.forTable), td:not(.forTable), tr:not(.forTable) {
  6.  display: block;
  7. }
  8. /* Hide table headers (but not display: none;, for accessibility) */
  9. table:not(.forTable) thead tr:not(.forTable) {
  10.  position: absolute;
  11.  top: -9999px;
  12.  left: -9999px;
  13. }
  14. td:not(.forTable) {
  15.  /* Behave  like a "row" */
  16.  position: relative;
  17. }
  18. td:not(.forTable):before {
  19.  /* Now like a table header */
  20.  position: absolute;
  21.  /* Top/left values mimic padding */
  22.  top: 6px;
  23.  left: 6px;
  24.  /*width: 45%; */
  25.  padding-right: 10px;
  26.  white-space: nowrap;
  27. }
  28. }

et donc pour les tableaux que je souhaites voir apparaitre normalement je fais

Code :
  1. <table class="forTable">
  2. <tbody class="forTable">
  3.  <tr class="forTable">
  4.   <th class="forTable">XXXX</th>
  5.   <td class="forTable">YYYYY</td>
  6.  </tr>
  7.  <tr class="forTable">
  8.   <th class="forTable">ZZZZZ</th>
  9.   <td class="forTable">AAAAAl</td>
  10.  </tr>
  11.  <tr class="forTable">
  12.   <th class="forTable">BBBBB</th>
  13.   <td class="forTable">CCCCCC</td>
  14.  </tr>
  15.  <tr class="forTable">
  16.   <td class="forTable" colspan="2">Long</td>
  17.  </tr>
  18. </tbody>
  19. </table>

Ceci est un exemple, mais notez l'obligation de devoir mettre un

Code :
  1. class="forTable"

partout.
 
Idéalement ça serait mieux d'avoir un code HTML :

Code :
  1. <table class="forTable">
  2. <tbody>
  3.  <tr>
  4.   <th>XXXX</th>
  5.   <td>YYYYY</td>
  6.  </tr>
  7.  <tr>
  8.   <th>ZZZZZ</th>
  9.   <td>AAAAAl</td>
  10.  </tr>
  11.  <tr>
  12.   <th>BBBBB</th>
  13.   <td>CCCCCC</td>
  14.  </tr>
  15.  <tr>
  16.   <td colspan="2">Long</td>
  17.  </tr>
  18. </tbody>
  19. </table>

Mais du coup comment écrire la CSS correspondante ?


Message édité par Aurelienazerty le 15-01-2014 à 21:40:08

---------------
http://lan.team-azerty.com, LAN fun en Rhône-Alpes
mood
Publicité
Posté le 15-01-2014 à 21:28:57  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  CSS 3 bonne utilisation du not pour usage adaptatif

 

Sujets relatifs
[CSS / Wordpress] Modification de la barre de menu[HTML/CSS]** HEEEELP PLEASE Comment retirer un pied de page en CSS ??
Menu CSS bouge si changement de résolution d'écran ou zoomTrouver la bonne série de nombres pour un résultat donné
Menu HTML/CSS[CSS] Cacher / afficher ligne tableau
3 boutons CSS dans la même page[CSS]Comment bouger mon menu ?
Besoin d'aide pour HTML/CSSCSS pour les nuls
Plus de sujets relatifs à : CSS 3 bonne utilisation du not pour usage adaptatif


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR