p:咆哮的自定义定位



我正在使用PrimeFaces 3.2的<p:growl>组件来显示人脸消息。我想自定义它的位置,使其显示在左侧而不是右侧。

我尝试了以下方法:

<h:head>
    <title>Facelet Title</title>
    <style type="text/css">
        .ui-growl {
            position:absolute;
            top:20px;
            left:20px;
            width:301px;
            z-index:9999;
        }
    </style>
</h:head>
<h:body>
    <h:form id="frm">
        <div id="add">
            <p:growl id="growl" showDetail="true" sticky="true" autoUpdate="true"/>
            <h:panelGrid columns="2" >
            ...

但它没有奏效。我错在哪里?

你的代码看起来不错。

我将其复制到我的测试用例中,它可以工作:咆哮元素显示在左上角。为此,只需要left:20px;(感谢@BalusC的评论(。

所以问题一定出在别的地方。您的页面是否有在示例中省略的其他样式定义?尝试通过删除所有不必要的内容来隔离问题。

这是我的测试用例:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Facelet Title</title>
        <style type="text/css">
            .ui-growl{
                left:20px;
            }
        </style>
    </h:head>
    <h:body>
        <h:form id="myform">
            <div id="add">
                <p:growl showDetail="true" sticky="true" autoUpdate="true"/>
            </div>
        </h:form>
    </h:body>
</html>
function growlLeft(){
                var css = document.createElement("style");
                css.id="growlStyle";
                css.type = "text/css";
                css.innerHTML = ".ui-growl { left: 20px!important}";
                document.body.appendChild(css);
            }
            function growlReset(){
                $('#growlStyle').empty();
            }

这段代码将有助于定位 DNAMLY 并重置其位置。 此外,样式类解决了以下问题:

                 .ui-growl { left: 20px}

最新更新