answered
2020-06-29 14:51:07 +0800
cor3000 6280 ● 2 ● 7 Apparently/unfortunately grid doesn't do what you expect (I won't argue whether this is intuitive or ideal).
As of now: only if pixel widths are set on all columns it considers the table to have fixed width (didn't test for hflex="min" yet), other units like %,em,rem,vw don't get this special treatment and the
elements has a width of 100% resulting in columns spanning over the whole width (increasing their width proportionally). I assume this behavior ranges back to the beginning of ZK where alternative units other than px and % were not widely spread.
So in short ZK doesn't implement a defined behavior for 'em' units in this case.
You provided multiple examples showing various effects based on this limitation.
Which is the one you need most so I can provide a workaround or custom styling approach if possible at all?
About your last question, it's easiest to specify an em width for the whole table and then use hflex only for the columns. Like that you can at least calculate/control the resulting widths in a deterministic way.
e.g:
https://zkfiddle.org/sample/25ebsv8/1-em-width-grid
UPDATE: (the comment below seems to provide a more suitable way)
... instead of using the width="8em"
property I applied an inline style
style="width:8em"
- seems to look alright
here:
https://zkfiddle.org/sample/1ajl3ur/3-Show-problems-with-mixing-hlfex-and-fixed-width