Search code examples
cssjsf-2primefaceswidthpanelgrid

How to change width of <p:panelGrid>


I have a <p:panelGrid> as follows:

<p:panelGrid style="width: 50px">
    <p:row>
        <p:column colspan="2">
            <p:inputTextarea/>
        </p:column>
    </p:row>
</p:panelGrid>

I tried to set the width of the panel grid to 50px by setting the CSS width property, however it didn't become 50px wide.

How can I set the width of the panel grid to 50px?


Solution

  • The <p:inputTextarea> is wider than the <p:panelGrid> and therefore pushing it far outside the specified width.

    You need to set the width on the <p:inputTextarea> as well.

    <p:inputTextarea style="width: 50px;" />
    

    (note: this doesn't take margins into account, so the panel grid is still a bit larger than 50px, but you should now know how to finetune that)


    Unrelated to the concrete problem, CSS should go in its own .css file.