我有以下的HTML和CSS:
table { border-collapse: collapse; } table.patients, table.patients > tr { width: 100%; } table.patients td, table.patients th { border: 1px solid black; } table.patients_patient_table tr, table.patients_patient_table td { border: 1px solid red; } .patients_appointment { text-align: left; width: 25%; } .patients_patient { text-align: left; width: 25%; padding: 0px; } .patients_patientID { text-align: left; width: 15%; } .patients_sex { text-align: left; width: 10%; } .patients_physician { text-align: left; width: 25%; } .patients_row { height: 4em; } .patients_patient_table { width: 100%; height: 100%; } body { font-family: verdana, sans-serif; margin: 0; padding: 0; }
<table class="patients"> <tr class="patients_row"> <td class="patients_appointment">12/20/2014 7:00am</td> <td class="patients_patient"> <table class="patients_patient_table"> <tr> <td>Smith, John</td> <td>55 Y</td> </tr> <tr> <td colspan=2>test</td> </tr> </table> </td> <td class="patients_patientID">5678</td> <td class="patients_sex">M</td> <td class="patients_physician">Dr. John Smith</td> </tr> </table>
结果如下表:
如果我更改CSS的.patients_patient
这样:
.patients_patient {
text-align: left;
width: 25%;
height: 100%;
padding: 0px;
}
table { border-collapse: collapse; } table.patients, table.patients > tr { width: 100%; } table.patients td, table.patients th { border: 1px solid black; } table.patients_patient_table tr, table.patients_patient_table td { border: 1px solid red; } .patients_appointment { text-align: left; width: 25%; } .patients_patient { text-align: left; width: 25%; height: 100%; padding: 0px; } .patients_patientID { text-align: left; width: 15%; } .patients_sex { text-align: left; width: 10%; } .patients_physician { text-align: left; width: 25%; } .patients_row { height: 4em; } .patients_patient_table { width: 100%; height: 100%; } body { font-family: verdana, sans-serif; margin: 0; padding: 0; }
<table class="patients"> <tr class="patients_row"> <td class="patients_appointment">12/20/2014 7:00am</td> <td class="patients_patient"> <table class="patients_patient_table"> <tr> <td>Smith, John</td> <td>55 Y</td> </tr> <tr> <td colspan=2>test</td> </tr> </table> </td> <td class="patients_patientID">5678</td> <td class="patients_sex">M</td> <td class="patients_physician">Dr. John Smith</td> </tr> </table>
随后,外表行的变化高度:
为什么会出现这种情况? 我真正想要的是结果是这样的:
编辑:我在Chrome测试此。