Globally changing default style in Primefaces

前端 未结 4 1108
孤独总比滥情好
孤独总比滥情好 2021-01-30 07:46

How should I change and apply changes to the default style of primefaces globally and only once?

.ui-widget,.ui-widget .ui-widget {
    font-size: 90% !important         


        
4条回答
  •  星月不相逢
    2021-01-30 08:08

    Create a style sheet file:

    /resources/css/default.css

    .ui-widget, .ui-widget .ui-widget {
        font-size: 90%;
    }
    

    (please note that I removed the !important "hack", see also How do I override default PrimeFaces CSS with custom styles? for an in-depth explanation of how to redefine PF styles)

    Include it in the of your template using (it will be auto-relocated to the end of the HTML head, after all PrimeFaces own stylesheets):

    
        
        ...
    
    

    If you aren't using a master template and thus need to include this in every single page, I recommend to reconsider your page design and to utilize JSF2 Facelets templating capabilities. This way you've only one master template file where all defaults of both the head and the body are definied. See also this answer for a concrete example: How to include another XHTML in XHTML using JSF 2.0 Facelets?

提交回复
热议问题