{"id":1061,"date":"2010-11-11T11:35:46","date_gmt":"2010-11-11T11:35:46","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1061"},"modified":"2011-09-22T11:15:22","modified_gmt":"2011-09-22T11:15:22","slug":"fonts-reduce-in-size-when-primefaces-table-moved-inside-a-panel","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1061","title":{"rendered":"Fonts reduce in size when Primefaces table moved inside a panel"},"content":{"rendered":"<p><strong><span style=\"text-decoration: underline;\">Update 22\/09\/2011<\/span><\/strong><\/p>\n<p>The following selector (as documented below) did not work when used for a particular table. CSS ignored the rule presumably for reasons of specificity:-<\/p>\n<p style=\"padding-left: 30px;\">.ss-nested-widget, .ss-nested-widget .ui-datatable {<br \/>\n\u00a0\u00a0\u00a0\u00a0 font-size: 100% !important;<br \/>\n}<\/p>\n<p>However, the following selector did work (and was also modified to include a dialog as well as a table). This has the advantage of not relying on having ss-nested-widget as a class on the table in order to work.<br \/>\n<strong>This has now been adopted as standard as the solution for this issue :-<\/strong><\/p>\n<p style=\"padding-left: 30px;\">.ss-nested-widget,<br \/>\n.ui-widget .ui-datatable,<br \/>\n.ui-widget .ui-dialog {\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0 font-size:100% !important;\u00a0\u00a0\u00a0<br \/>\n}<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Original Post<\/span><\/strong><\/p>\n<p>This issue is due to font size inheritance.<\/p>\n<p>My default font for all Primefaces components was specified globally as follows:-<\/p>\n<p style=\"padding-left: 30px\">.ui-widget {<\/p>\n<p>font-size: 75% !important;<\/p>\n<p>}<\/p>\n<p>The reason for this is that in general it is considered more flexible to go for percentage sizes as these can then be scaled automatically when viewed on smaller devices.<\/p>\n<p>Unfortunately, it appears that when for example a table is nested inside a panel, the font size appears to be 75% of 75% as the rule is inherited and applied twice, as 75% is a relative measurement, The table ends up rendered as a 9px font which is too small. The situation is further complicated by the fact that in the Primefaces skinning, there is a mixture of fonts specified in ems, percentages and pixel sizes, which means that not everything is specified in relative sizing anyway.<\/p>\n<p>There are 2 solutions to the issue, both are straightforward, 1\/ is the simplest although arguably not the best due to absolute sizing:-<\/p>\n<p>1\/ Change the global <em>ui-widget<\/em> rule above to use a fixed font size (12px works as a replacement for the above 75%)<\/p>\n<p style=\"padding-left: 30px\">.ui-widget {<\/p>\n<p>font-size: 12px !important;<\/p>\n<p>}<\/p>\n<p>2\/ Keep the\u00a0 75%\u00a0 for <em>ui-widget<\/em> and introduce a new rule to specify a 100% size for nested elements:-<\/p>\n<p style=\"padding-left: 30px\">.ss-nested-widget {<\/p>\n<p>font-size:100% !important;<\/p>\n<p>}<\/p>\n<p>This rule needs to be introduced inside the panel. If it is placed on the panel itself, which is the parent element, then the font size just \u2018goes large\u2019 to 100%, i.e. larger than the desired default font. To obtain the correct behaviour, the sub-elements inside the panel must be tagged with the style class. It is possible to tag an enclosing &lt;div&gt; just inside the panel, so that the sub-elements inherit it. However, whilst this worked for input selectors and buttons in the panel, tables refused to play ball, and the following rule was needed to ensure that a table in the panel inherited the correct size:-<\/p>\n<p style=\"padding-left: 30px\">.ss-nested-widget, .ss-nested-widget .ui-datatable {<\/p>\n<p>font-size: 100% !important;<\/p>\n<p>}<\/p>\n<p>The same kind of trick can be used to target other nested elements which do not inherit the correct size.<\/p>\n<p>An alternative method would be just to add the class to sub-elements individually where required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update 22\/09\/2011 The following selector (as documented below) did not work when used for a particular table. CSS ignored the rule presumably for reasons of specificity:- .ss-nested-widget, .ss-nested-widget .ui-datatable { \u00a0\u00a0\u00a0\u00a0 font-size: 100% !important; } However, the following selector did work (and was also modified to include a dialog as well as a table). This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[79],"tags":[189,40,78,112,16],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1061"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1061"}],"version-history":[{"count":8,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1061\/revisions"}],"predecessor-version":[{"id":1065,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1061\/revisions\/1065"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}