【问题标题】:Disallow child elements to inherit styles from parent element/s禁止子元素从父元素继承样式
【发布时间】:2014-11-01 12:46:57
【问题描述】:

例如<p:fileUpload>,通常显示如下。

它基本上在其他一些 HTML 元素中呈现一个 HTML 表格。生成的表格代码如下所示。

<table class="ui-fileupload-files">
    <tbody>
        <tr>
            <td class="ui-fileupload-preview">
                <canvas width="80" height="60"></canvas>
            </td>

            <td>Winter.jpg</td>
            <td>103.1 KB</td>

            <td class="ui-fileupload-progress">
                <div class="ui-progressbar ui-widget ui-widget-content ui-corner-all" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
                    <div class="ui-progressbar-value ui-widget-header ui-corner-left" style="display: none; width: 0%;"></div>
                </div>
            </td>

            <td>
                <button class="ui-fileupload-cancel ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only">
                    <span class="ui-button-icon-left ui-icon ui-icon ui-icon-close"></span>
                    <span class="ui-button-text">ui-button</span>
                </button>
            </td>
        </tr>
    </tbody>
</table>

请注意表格单元格周围没有边框(以及其他样式)(HTML 表格中的规则)。


如果&lt;p:fileUpload&gt; 显示在&lt;p:dataTable&gt; 中,例如,&lt;p:dataTable&gt; 中的样式会自动应用于为&lt;p:fileUpload&gt; 显示的表格,如下所示。

来自给定&lt;p:dataTable&gt; 的样式应用于&lt;p:fileUpload&gt;,如图所示。

这个&lt;p:fileUpload&gt;可以用下面的XHTML代码显示。

<p:dataTable id="dataTable" var="row" value="Value"
             rows="3"
             rowIndexVar="rowIndex"
             style="width: 50%;">

    <p:column headerText="Index">
        <h:outputText value="#{rowIndex+1}"/>
    </p:column>

    <p:column headerText="Image">
        <p:graphicImage id="image"
                        library="default"
                        name="test/Sunset.jpg"
                        height="100" width="100"/>

        <p:overlayPanel for="image"
                        at="left top" my="right bottom" 
                        style="width: 500px; display: none;"
                        showCloseIcon="true" dismissable="true">

            <p:fileUpload fileLimit="1"
                          allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
                          fileUploadListener="#{bean.listener}"/>
        </p:overlayPanel>
    </p:column>
</p:dataTable>

无论如何都可以阻止这种情况,以便&lt;p:dataTable&gt; 中的样式不会应用于&lt;p:fileUpload&gt; 并且&lt;p:fileUpload&gt; 可以像第一张图片中所示的那样正常显示吗?

【问题讨论】:

    标签: css jsf primefaces jsf-2.2


    【解决方案1】:

    不幸的是,如果您不希望它们使用父级的 css,则必须手动覆盖所有这些值。

    【讨论】:

    • 对。我会没有它。
    猜你喜欢
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-23
    相关资源
    最近更新 更多