Although few tables are currently used, some writing operations still need to be used.
Today, when I was working on the F7Dialog2.0 project, I encountered the CSS width and height for getting table cells. I think it is very easy to get the width and height. I directly wrote the code to get it. Later, when the Code was written, I found that the chrome execution results were different and it was very depressing.
After finding the cause for half an hour, I finally found that the difference occurred when getting the cell CSS height in chrome.
Cause: different browsers have different execution results on tables.
Solution:
Later, we tested the CSS parameter acquisition in the TABLE and found that we performed border-collapse: collapse; setting on the TABLE, and set the display: block for TR and TD, at this time, the width and height of any element are obtained, and the browsers will be consistent. If this is not set, it can be said that the results obtained by the browsers vary.
My own mistake is that the display: block is not set for TD;
The specific test code is as follows:
<Style>
. Muheight {height: 100px; width: 200px; border-collapse: collapse ;}
. Muheight tr {display: block ;}
. Muheight td {display: block ;}
. MWR {height: 80px; width: 150px ;}
. D_left_up {height: 50px; width: 110px ;}
</Style>
<Table class = "muheight">
<Tr class = "mhowever">
<Td class = "D_left_up"> </td>
</Tr>
</Table>
<Script>
Alert (F $ (". muheight" ).css ("width "));
Alert (F $ (". muheight" ).css ("height "));
Alert (F $ (". mtranslated" ).css ("width "));
Alert (F $ (". mtranslated" ).css ("height "));
Alert (F $ (". D_left_up" ).css ("width "));
Alert (F $ (". D_left_up" ).css ("height "));
</Script>
Note: F $ (").css (" ") is just a small framework that I have compiled myself. It is the same as Jquery.
Other methods:
The results obtained by. scrollWidth are more different. At that time, because CSS was used to define the width and height in the cells I want to take, I did not study such methods in detail.