如何在jQuery Mobile中覆盖面板后面变暗?

问题描述 投票:0回答:1

我从jQuery Mobile网站上获取了面板代码并将其合并到我的文件中。当屏幕上显示时,我想使面板后面的内容变暗或模糊。我尝试过使用filter:blur(5px),但无济于事。我使用正确的语法吗?请查看图片以获得理想的结果。

HTML:

<!-- Subheader --> 
        <div data-role="header" class="subheader" data-position="fixed">
            <a href="#filterPanel" class="ui-btn-right" >Filter</a>
            <div class="subheadertext">Available job opportunities...</div>
        </div>

            <!-- Subheader Filter Panel -->
            <div data-role="panel" id="filterPanel" data-display="overlay" data-position="right">
                <p>This will be the filter panel</p>
            </div>

CSS:

/* Subheader Filter Panel */

#filterPanel {
    background-color: #99c5cc;
    color: white;
    text-shadow: none;
}

enter image description here

jquery css jquery-ui jquery-mobile
1个回答
1
投票

您只能将过滤器属性blur()应用于图像或SVG:https://www.w3.org/TR/filter-effects-1/#funcdef-blur

在您想要模糊HTML内容的情况下,最好的做法是将不透明度应用于位于内容上的元素。在侧面板打开时查看jQuery mobile它实际上提供了这种类型的叠加。

尝试将此CSS添加到您的项目中:

.ui-panel-dismiss-open {
  background: rgba(0, 0, 0, 0.8) !important;
}

查看在jQuery Mobile网站上工作的屏幕截图(请注意控制台中的CSS):

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.