[Risolto] [CSS] Stesso width di th e td di due tabelle diffe

Linguaggi di programmazione: php, perl, python, C, bash e tutti gli altri.
TommyB1992
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 862
Iscrizione: domenica 7 luglio 2013, 15:55
Desktop: GNU/Linux
Distribuzione: Ubuntu 22.04.2 LTS
Sesso: Maschile

[Risolto] [CSS] Stesso width di th e td di due tabelle diffe

Messaggio da TommyB1992 »

Codice: Seleziona tutto

<!DOCTYPE html><html><head>
<style>
 * {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Arial, sans-serif;
}
table{
  width:100%;

}
.tbl-header{
  background-color: #fff;
  background-color: #f5f5f6

 }
.tbl-content{
  height:300px;
  overflow-x:auto;
  margin-top: 0px;

}
th{    

  font-weight: bold;
  text-align: left;
  font-size: 12px;
  color: #949494;;
  text-transform: uppercase;
  width: 20px;
  padding:10px;
  border-right: 1px solid #ebebeb;
}
td{

  text-align: left;
  font-size: 12px;
  color: #fff;
  color: #949494;;
  border-bottom: 1px solid #ebebeb;
  border-right: 1px solid #ebebeb;
  width: 10px;
  padding:10px;
}
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
</style>
</head><body>

  <div class="tbl-header">
    <table>
      <thead>
        <tr>
          <th>a</th>
          <th>b</th>
          <th>c</th>
          <th>d</th>
          <th>e</th>
        </tr>
      </thead>
    </table>
  </div>
  <div class="tbl-content">
    <table>
      <tbody>
        <tr>
          <td>dassd</td>
          <td>2123123 </td>
          <td>12231</td>
          <td>asdasdd</td>
          <td>sdaasd21323</td>
        </tr>
      </tbody>
    </table>
  </div>

</body></html>
Se salvate il codice noterete che i border dei th e td sono differenti.
Come risolvo?
Ultima modifica di TommyB1992 il martedì 16 maggio 2017, 15:47, modificato 1 volta in totale.
Avatar utente
Danny90
Prode Principiante
Messaggi: 147
Iscrizione: sabato 9 maggio 2015, 20:05
Sesso: Maschile
Località: Dresden (Germany)
Contatti:

Re: [CSS] Stesso width di th e td di due tabelle differenti

Messaggio da Danny90 »

Intendi che lo vorresti così?

Codice: Seleziona tutto

<!DOCTYPE html><html><head>
<style>
 * {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Arial, sans-serif;
}
table{
  width:100%;

}
.tbl-header{
  background-color: #fff;
  background-color: #f5f5f6

 }
.tbl-content{
  height:300px;
  overflow-x:auto;
  margin-top: 0px;

}
th{   

  font-weight: bold;
  text-align: left;
  font-size: 12px;
  color: #949494;;
  text-transform: uppercase;
  width: 20px;
  padding:10px;
  border-right: 1px solid #ebebeb;
}
td{

  text-align: left;
  font-size: 12px;
  color: #fff;
  color: #949494;;
  border-bottom: 1px solid #ebebeb;
  border-right: 1px solid #ebebeb;
  width: 70px;
  padding:10px;
}
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
</style>
</head><body>

  <div class="tbl-header">
    <table>
      <thead>
        <tr>
          <th>a</th>
          <th>b</th>
          <th>c</th>
          <th>d</th>
          <th>e</th>
        </tr>
      </thead>
    </table>
  </div>
  <div class="tbl-content">
    <table>
      <tbody>
        <tr>
          <td>dassd</td>
          <td>2123123 </td>
          <td>12231</td>
          <td>asdasdd</td>
          <td>sdaasd21323</td>
        </tr>
      </tbody>
    </table>
  </div>

</body></html>
Im schlechten Kleide wohnt oft auch Weisheit.
Avatar utente
UbuNuovo
Imperturbabile Insigne
Imperturbabile Insigne
Messaggi: 4457
Iscrizione: sabato 12 dicembre 2009, 20:58
Desktop: Mate
Distribuzione: Ubuntu Mate 22.04.1 LTS
Sesso: Maschile
Contatti:

Re: [CSS] Stesso width di th e td di due tabelle differenti

Messaggio da UbuNuovo »

Visto che usi la larghezza della tabella in percentuale, ti conviene impostare 'width: 20%;' sia in 'th' che in 'td'
Salva l'Ucraina! 🇺🇦
TommyB1992
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 862
Iscrizione: domenica 7 luglio 2013, 15:55
Desktop: GNU/Linux
Distribuzione: Ubuntu 22.04.2 LTS
Sesso: Maschile

Re: [Risolto] [CSS] Stesso width di th e td di due tabelle d

Messaggio da TommyB1992 »

Grazie dell'aiuto a tutti e due
Scrivi risposta

Ritorna a “Programmazione”

Chi c’è in linea

Visualizzano questa sezione: 0 utenti iscritti e 2 ospiti