prem
prem

Reputation: 71

Primefaces dialog to set height half screen size

I am using Primefaces 5.1. In my page I use dialog and height attribute. I need to set screen size 70% of height to dialog because screen height differ from all system so I need to set dynamic height. I need what javascript or css used to set screen based to height?

<p:dialog widgetVar="dialogWidget" id="dialogId" position="center,top" height="height to set">
........
</p:dialog>

Upvotes: 0

Views: 6828

Answers (2)

Michele Mariotti
Michele Mariotti

Reputation: 7459

<p:dialog style="height: 70vh" ... or <p:dialog height="70vh" ...

Upvotes: 1

Subodh Joshi
Subodh Joshi

Reputation: 13512

First define a css class

.autoWidthDialog {
    width: auto !important;
}

Then use above css in your dialogbox

<p:dialog id="dialog" styleClass="autoWidthDialog" header="My dialog">
  ... content ...
</p:dialog>

This is very old workaround for this, may be in latest Primefaces they have added autosize attribute.

Another solution can be use some style with style attribute

<p:dialog ... modal="true" style="width:50% !important; height:40% !important; top:25% !important; left: 30% !important;">

</p:dialog>

Upvotes: 0

Related Questions