CSS Primefaces 对话框滚动条未显示在标题下方

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24575913/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:40:59  来源:igfitidea点击:

Primefaces dialog scrollbar not showing up below the header

cssjsfprimefacesel

提问by user3737958

I am using the following primefaces dialog and I added scrolling after a max height using the style attribute below.

我正在使用以下 primefaces 对话框,并使用下面的样式属性在最大高度之后添加了滚动。

However, the scrollbar is not showing up within the header and as a result, when I scroll, the header scrolls along with the contents of the dialog.

但是,滚动条没有显示在标题中,因此,当我滚动时,标题会随着对话框的内容一起滚动。

<p:dialog header="#{resName}" widgetVar="resDialog" resizable="false" style="max-height:900px;overflow:auto">

I don't want the header to scroll and preferably, I also want the scrollbar to show under the header

我不希望标题滚动,最好,我还希望滚动条显示在标题下

Any ideas?

有任何想法吗?

回答by rion18

Get rid of your overflow:auto;and put every content from your dialog inside a p:scrollPanel(check here).

摆脱你的overflow:auto;并将对话框中的所有内容放在 a 中p:scrollPanel(检查这里)。

回答by Jaqen H'ghar

I find it easier to do like this:

我发现这样做更容易:

.ui-dialog-content{ 
    max-width: 950px !important; 
    max-height: 700px !important;
    margin-bottom: 5px !important;
}

That should target all dialogs at once.

这应该一次针对所有对话框。

To open the dialog and scroll to the top of it (if it has been open before) do

要打开对话框并滚动到它的顶部(如果之前已经打开过),请执行以下操作

<p:commandButton .... 
   oncomplete="PF('dialogwv').show(); PF('dialogwv').content.scrollTop('0')" />

Note: the two PF-calls cannot be switched around, but in praxis it does'nt matter..

注意:这两个 PF 调用不能切换,但在实践中并不重要。

回答by tnas

Another very simple alternative could be the use of the positionTypeproperty of the dialog.

另一个非常简单的替代方法是使用positionType对话框的属性。

<p:dialog header="#{resName}" widgetVar="resDialog" resizable="false" positionType="absolute">