html - How to apply different styles based on the number oif col in a table -
I have different tables that are similar but the only difference is that they can have different columns. I want to define a style that if the number of columns is 2, then the width of TD will be 80% and the second width will be 105. If there are three columns in the table, their width is 45%, 45% and 10% and so on.
How can I do this in CSS? If this is not possible in CSS, how can I do this in JQuery?
That is, as far as I know, just do not have to work with CSS because You need to calculate the percentage and find out the number of columns.
I set up with a jQuery instance, assuming the same number of columns for each row (no colspan used). Here's how I did it:
var cols = $ ('table tr: first td'). Size (), width = 90 / cols, last_width = 10; $ ('Table TD'). CSS ('width', width + "%"); $ ('Table tr & gt; td: last-child'). CSS ('width', final_date + "%"); a???? The number of used Vars columns, the last column size, and other column sizes (90% width depending on the number of columns) are. Then we apply the resulting width to all cells, and the last row width applies to the last cell of each row.
Comments
Post a Comment