【问题标题】:md-toolbar background-color: transparent not workingmd 工具栏背景颜色:透明不起作用
【发布时间】:2016-04-08 05:43:17
【问题描述】:

我一直在努力解决这个问题......我不知道为什么即使我更改了 CSS,我的 md 工具栏的背景仍然是白色的。

我在这里有一个项目示例:

http://abc.morado.xyz:32782/#/index

呈现所有视图的默认 HTML 页面如下所示:

<div layout="row" class="full-height transparent">
<!-- left sidebar -->

<!--<md-sidenav class="admin-sidebar-left md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="layout.sideMenuSize !== 'hidden' && $mdMedia('gt-sm')" ui-view="sidebarLeft" ng-class="{ 'admin-sidebar-collapsed': layout.sideMenuSize == 'icon' }" ng-mouseover="layoutController.activateHover()" ng-mouseleave="layoutController.removeHover()"></md-sidenav>-->

<!-- main content -->
<div id="admin-panel" layout="column" flex class="transparent">
    <!-- loading animation -->
    <tri-loader></tri-loader>

    <!-- top toolbar -->
    <md-toolbar class=" transparent" ng-if="layout.showToolbar" md-theme="{{triSkin.elements.toolbar}}" ui-view="toolbar" ng-class="[layout.toolbarSize,layout.toolbarClass]"></md-toolbar>

    <!-- scrollable content -->
    <md-content ng-class="layout.contentClass" flex tri-default-content ui-view="content"></md-content>

    <div ui-view="belowContent"></div>
</div>

<!-- right sidebar -->
<md-sidenav layout layout-fill class="md-sidenav-right md-whiteframe-z2" md-component-id="notifications" ui-view="sidebarRight"></md-sidenav>

标题会在我的配置文件中呈现:

.state('triangular.header', {
            abstract: true,
            views: {
                toolbar: {
                    templateProvider: function($templateCache, $http, triLayout) {
                        return $http.get(triLayout.layout.toolbarTemplateUrl, {cache: $templateCache })
                            .then(function(response) {
                                return response.data;
                            });
                    },
                    controllerProvider: function(triLayout) {
                        return triLayout.layout.toolbarController;
                    },
                    controllerAs: 'vm'
                },
                content: {
                    templateProvider: function($templateCache, $http, triLayout) {
                        return $http.get(triLayout.layout.contentTemplateUrl, {cache: $templateCache })
                            .then(function(response) {
                                return response.data;
                            });
                    }
                },
                belowContent: {
                    template: '<div ui-view="belowContent"></div>'
                }
            }
        })

我在网上看到了这些解决方案,但在我的情况下它们不起作用...

https://github.com/angular/material/issues/4379

My own styles in angular material ui

如果您转到我上面的链接并尝试自己使用 CSS,您会发现在 md-toolbar 标记或所述标记内的 div 上设置背景只会使背景变成不透明的白色。

感谢您的帮助!

【问题讨论】:

    标签: angularjs material-design angular-material


    【解决方案1】:

    我不知道我的 md-toolbar 的背景何时保持白色,即使我更改了 CSS

    该元素的背景透明的,正如您在 CSS 中指定的那样。

    你看到的白色只是body元素的背景。

    【讨论】:

    • 我没看到你在哪里看到 #admin-panel background-color 是白色的?
    • 对不起,你是对的,不是那个——它只是身体背景。但我不确定你是如何期待这里有任何不同的结果的——当一个元素有透明背景时,它下面的任何东西都会“发光”,这是很自然的。
    • 那么,在那种情况下,无论如何制作一个粘性标题工具栏并且没有任何背景?有点像这个例子? projects.invisionapp.com/share/HU6O2XEY7/#/screens/146030680
    • 我的观点是,如果背景是透明的,为什么其余的内容(即图片等)不透光?
    • 那是因为您只使 md-content 元素内的内容可滚动,而不是整个页面作为一个整体。
    猜你喜欢
    • 2017-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 2012-06-26
    • 2013-02-05
    相关资源
    最近更新 更多