Ho creato due tabelle e voglio impostare lo width
delle 3 colonne di destra in base alla dimensione del primo. Ho provato calc((100% - 200px)/3)
ma non funziona con tutti i browser: Firefox 40 fallisce, IE11 fallisce e Chrome 44 sembra farlo bene. Come posso fare in modo che calc()
sia compreso in tutti i browser? O dovrei semplicemente dimenticarlo?calc() non calcola in CSS, differenze nei browser
Ho creato una versione molto più semplice che fallisce altrettanto bene.
<table class="tableauTable">
<thead>
<tr class="tableauRow first">
<th colspan="3" rowspan="2" class="tableauCell first"><span class="xspTextComputedField">Objet - Acteurs</span>
</th>
<th class="tableauCell header col3"><span class="xspTextComputedField">Julien GARDIN</span>
</th>
<th class="tableauCell header col3"><span class="xspTextComputedField">Justine VINCLAIR</span>
</th>
<th class="tableauCell header col3"><span class="xspTextComputedField">Marcel COMMAS</span>
</th>
</tr>
</thead>
<tfoot>
<tr class="tableauRow first">
<th colspan="3" header="" class="tableauCell first"></th>
<th class="tableauCell header col3"><span class="xspTextComputedField">Julien GARDIN</span>
</th>
<th class="tableauCell header col3"><span class="xspTextComputedField">Justine VINCLAIR</span>
</th>
<th class="tableauCell header col3"><span class="xspTextComputedField">Marcel COMMAS</span>
</th>
</tr>
</tfoot>
</table>
Lo stesso, con calc()
:
<table class="tableauTable">
<thead>
<tr class="tableauRow first">
<th colspan="3" rowspan="2" class="tableauCell first"><span class="xspTextComputedField">Objet - Acteurs</span>
</th>
<th class="tableauCell header col3x"><span class="xspTextComputedField">Julien GARDIN</span>
</th>
<th class="tableauCell header col3x"><span class="xspTextComputedField">Justine VINCLAIR</span>
</th>
<th class="tableauCell header col3x"><span class="xspTextComputedField">Marcel COMMAS</span>
</th>
</tr>
</thead>
<tfoot>
<tr class="tableauRow first">
<th colspan="3" header="" class="tableauCell first"></th>
<th class="tableauCell header col3x"><span class="xspTextComputedField">Julien GARDIN</span>
</th>
<th class="tableauCell header col3x"><span class="xspTextComputedField">Justine VINCLAIR</span>
</th>
<th class="tableauCell header col3x"><span class="xspTextComputedField">Marcel COMMAS</span>
</th>
</tr>
</tfoot>
Il CSS:
.tableauTable {
width:100%;
border-spacing: 1px;
}
.tableauRow.first .tableauCell {
background: #d2d2d2 none repeat scroll 0 0 !important;
text-align: center;
}
.tableauCell.first {
width: 150px;
}
.tableauCell.col3 {
width: 30%;
}
.tableauCell.col3x {
width: calc(30%);
}
.tableauCell.first {
background: #d2d2d2 none repeat scroll 0 0 !important;
text-align: center;
}
.tableauCell {
background: #eee none repeat scroll 0 0;
border: 2px solid white;
color: black;
}
Vedi http://jsfiddle.net/sjefb/19vrf52o/
Sembra che non si tratti di un problema di compatibilità del browser [tuttavia] (http://caniuse.com/#feat=calc) –
Potresti essere un po 'più specifico riguardo a cosa significa "non funziona"? Non è il layout come ti aspetti? Il layout viene ignorato? Ha fatto crashare il browser? Secondo http://caniuse.com/#feat=calc, è possibile che venga emesso un problema a causa del modo in cui i diversi browser gestiscono i sottopixel. – GordonM
Hai aperto il violino? Vedrai che quando la larghezza di col3 è impostata al 30%, tutti i browser si comportano correttamente, mentre quando la larghezza è impostata su calc (30%) solo Chrome sembra funzionare. –