盒子阴影没出现?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了盒子阴影没出现?相关的知识,希望对你有一定的参考价值。

我正在使用谷歌聚合物网络组件来设计样式,但顶部工具栏的顶部阴影没有显示出来。

底部阴影效果很好。此外,即使我将顶部工具栏和底部工具栏的z-index设置为高于抽屉打开时的抽屉,我仍然看到抽屉在顶部打开但它在底部工作。

Drawer Closed:

Drawer Closed

Drawer Opened:

Drawer Opened

这是我的代码:

<dom-module id="bollu-app">
  <template>
    <style>
      :host {

        display: block;
      }

      app-drawer-layout:not([narrow]) [drawer-toggle] {
        display: none;


      }

      app-header {
        color: #FBFFFF;



      }

      app-header paper-icon-button {
        --paper-icon-button-ink-color: #FBFAFC;
      }

      app-toolbar.top {

        padding: 0 16px;
        top: 0;
        background-color: #121D23;
        position: fixed;
        width: 100%;
        height: 50px;
        z-index: 3;
        box-shadow: inset 0px 5px 2px -3px rgba(0, 0, 0, 0.2);

      }

      app-toolbar.bottom {
        background-color: #121D23;
        bottom: 0;
        position: fixed;
        width: 100%;
        height: 50px;
        z-index: 3;
        box-shadow: inset 0px 5px 2px -3px rgba(0, 0, 0, 0.2);
      }

      app-drawer {
        --app-drawer-content-container: {
          background-color: #FBFAFC;
          z-index: 1;


        }

      }

      .page {
        background-color: #090A11;
        width: 100vh;
        height:100vh;
        z-index: -1;
      }

      .drawer-list {
        margin: 0 20px;
      }

      .drawer-list a {
        display: block;
        padding: 0 16px;
        font-family: "Lucida Console", Monaco, monospace;
        font-size: 20px;
        text-decoration: none;
        text-shadow: 2px 2px;
        text-align: center;
        color: #0B1016;
        background-color: #FBFAFC;
        line-height: 110px;
      }

      .drawer-list a.iron-selected {
        color: #0B1016;
        font-weight: bolder;
      }


    </style>

    <app-location
        route="{{route}}"
        url-space-regex="^[[rootPath]]">
    </app-location>

    <app-route
        route="{{route}}"
        pattern="[[rootPath]]:page"
        data="{{routeData}}"
        tail="{{subroute}}">
    </app-route>

    <app-drawer-layout fullbleed narrow="{{narrow}}">
      <!-- Drawer content -->
      <app-drawer id="drawer" slot="drawer" swipe-open="[[narrow]]">
        <app-toolbar class="top"></app-toolbar>
        <iron-selector selected="[[page]]" attr-for-selected="name" class="drawer-list" role="navigation">
          <a name="confessions-page" href="[[rootPath]]confessions-page">Confessions</a>
          <a name="gossip-page" href="[[rootPath]]gossip-page">Gossip</a>
          <a name="discover-page" href="[[rootPath]]discover-page">Discover</a>
          <a name="insights-page" href="[[rootPath]]insights-page">Insights</a>
          <a name="settings-page" href="[[rootPath]]settings-page">Settings</a>
        </iron-selector>
      </app-drawer>

      <!-- Main content -->
      <app-header-layout has-scrolling-region>

        <app-header slot="header" condenses reveals effects="waterfall">
          <app-toolbar class="top">
            <paper-icon-button icon="my-icons:menu" drawer-toggle></paper-icon-button>
            <div main-title>B</div>
          </app-toolbar>
        </app-header>


        <iron-pages
            selected="[[page]]"
            attr-for-selected="name"
            fallback-selection="view404"
            role="main">
          <confessions-page name="confessions-page"></confessions-page>
          <gossip-page name="gossip-page"></gossip-page>
          <discover-page name="discover-page"></discover-page>
          <insights-page name="insights-page"></insights-page>
          <settings-page name="settings-page"></settings-page>
          <my-view404 name="my-view404"></my-view404>
        </iron-pages>
      </app-header-layout>
    </app-drawer-layout>

    <app-toolbar class="bottom"></app-toolbar>

      <div class="page"></div>

  </template>

  <script>
    // Gesture events like tap and track generated from touch will not be
    // preventable, allowing for better scrolling performance.
    Polymer.setPassiveTouchGestures(true);

    class BolluApp extends Polymer.Element {
      static get is() { return 'bollu-app'; }

      static get properties() {
        return {
          page: {
            type: String,
            reflectToAttribute: true,
            observer: '_pageChanged',
          },
          routeData: Object,
          subroute: Object,
          // This shouldn't be neccessary, but the Analyzer isn't picking up
          // Polymer.Element#rootPath
          rootPath: String,
        };
      }

      static get observers() {
        return [
          '_routePageChanged(routeData.page)',
        ];
      }

      _routePageChanged(page) {
        // If no page was found in the route data, page will be an empty string.
        // Default to 'discoverPage' in that case.
        this.page = page || 'discover-page';

        // Close a non-persistent drawer when the page & route are changed.
        if (!this.$.drawer.persistent) {
          this.$.drawer.close();
        }
      }

      _pageChanged(page) {
        // Load page import on demand. Show 404 page if fails
        const resolvedPageUrl = this.resolveUrl(page + '.html');
        Polymer.importHref(
            resolvedPageUrl,
            null,
            this._showPage404.bind(this),
            true);
      }

      _showPage404() {
        this.page = 'my-view404';
      }
    }

    window.customElements.define(BolluApp.is, BolluApp);
  </script>
</dom-module>

谢谢。

答案

我们遇到了类似的错误,这是Google Chrome中的一个错误,Chrome 69的更新为我们解决了这个问题。

以上是关于盒子阴影没出现?的主要内容,如果未能解决你的问题,请参考以下文章

css有用的代码片段

div盒子存在阴影导致父级标签出现滚动条

如何在底部和所有侧面创建带有盒子阴影的容器

CSS学习15-盒子阴影

探索盒子阴影box-shadow

盒子模型成分结构以及水平/垂直方向布局,阴影,圆角