Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove scrollbar in PrimeFaces dialog?

Tags:

css

primefaces

I have ajax loading modal dialog in my webapp:

<p:dialog widgetVar="statusDialog" modal="true" draggable="false" minimizable="false" appendToBody="true"
    closable="false" header="Processing..." resizable="false" maximizable="false" style="overflow:hidden !important; overflow-x: hidden !important; width:auto;">  
     <p:graphicImage library="assets" name="ajax-loader.gif" style="overflow:hidden !important; overflow-x: hidden !important;"></p:graphicImage> 
</p:dialog>
<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  

No matter what CSS styles (I tried various combinations of overflow/overflow-x etc) I use it still displays horizontal (vertical is hidden, no problems there) scrollbar. I also played around with appendToBody attribute.

I need to disable the horizontal scrollbar.

EDIT: this is the HTML rendered by PrimeFaces

<div id="j_idt18" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ui-overlay-hidden" style="overflow: hidden; width: auto; height: auto; left: 832px; top: 210px; visibility: hidden; z-index: 1003; display: block;" role="dialog" aria-labelledby="j_idt18_title" aria-hidden="true" aria-live="off">
<div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top">
<span id="j_idt18_title" class="ui-dialog-title">Processing...</span>
</div>
<div class="ui-dialog-content ui-widget-content" style="height: auto;"><img id="j_idt19" src="/webapp/do/javax.faces.resource/ajax-loader.gif?ln=assets" alt="">
</div>
</div>

I have been able to get rid of the scrollbar by overriding default dialog CSS in my own stylesheet:

.ui-dialog-content {
    overflow: hidden !important;
}

However, this affects all dialogs, not just the ajax loading one. I want to be able to override that style on per-dialog basis. How do I do that?

like image 596
rootkit Avatar asked Feb 22 '13 16:02

rootkit


People also ask

How to prevent Scrolling in CSS?

Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.

How to prevent body from Scrolling When a modal is opened using CSS?

Approach: A simple solution to this problem is to set the value of the “overflow” property of the body element to “hidden” whenever the modal is opened, which disables the scroll on the selected element.


1 Answers

In you statusDialog dialog add styleClass="disable-scroll".

Also, create CSS rule for this:

.disable-scroll .ui-dialog-content {
  overflow: hidden !important;
}

This will apply CSS to all dialogs with this custom class.

like image 182
partlov Avatar answered Sep 17 '22 10:09

partlov