admin管理员组

文章数量:1406926

I am having an issue with my site creating two scroll bars. I am using md-toolbar for my nav (which I want to be stuck to the top throughout) and md-content to hold my content. When I scroll the nav stays stuck to the top but creates an extra scroll bar. (see to the right of the pic there is two scroll bars)

Here is my index.html:

<body ng-cloak ng-app="TrooNews" ng-controller="AppController as app">

        <!--top toolbar-->
        <md-toolbar class="md-shadow-bottom-z-1">
            <div class="md-toolbar-tools">
                <md-button class="md-icon-button" ng-click="app.toggleSidenav('left')" hide-gt-md1 aria-label="Menu">
                    <md-icon>menu</md-icon>
                </md-button>
                <a href="/home"><h1>Troo News</h1></a>
                <span flex></span>
                <md-button class="md-icon-button" ng-click="" hide-gt-md1 aria-label="Search">
                    <md-icon>search</md-icon>
                </md-button>
            </div>
        </md-toolbar>

        <!--left sidenav-->
        <div layout="row" layout-fill flex>
            <md-sidenav layout="column" class="md-sidenav-left md-whiteframe-z2" md-ponent-id="left">
                <md-toolbar></md-toolbar>
                <md-content flex role="navigation">
                    <md-list>
                        <md-list-item ng-repeat="item in app.menu" ng-click="app.navigateTo(item.link)">
                            <md-icon>{{item.icon}}</md-icon>
                            <p>{{item.title}}</p>
                        </md-list-item>
                    </md-list>
                </md-content>
            </md-sidenav>
            <div layout="column" layout-fill ng-viewport></div>
        </div>

        <div ng-view class="content"></div>

    </body>

And my html for my card view:

<md-content class="container-fluid">
    <section class="content-section">
      <div layout="column" layout-align="center" ng-style="{'width': '100%'}">
        <div class='md-padding' layout="row" layout-align="center" flex-offset-sm="0" flex-offset-md="0" flex-offset-lg="0" flex-offset-gt-lg="0" layout-wrap>
          <md-card ng-repeat="article in home.articles">
            <img ng-src="{{article.imagePath}}" class="md-card-image" alt="Test image">
            <md-card-title>
              <md-card-title-text>
                <a href="/article/{{article.id}}"><span class="md-headline">{{article.title}}</span></a>
              </md-card-title-text>
            </md-card-title>
            <md-card-content>
              <p>
                {{article.text}}
              </p>
            </md-card-content>
            <md-card-actions layout="row" layout-align="end center">
              <md-button class="md-icon-button" aria-label="Report">
                <md-icon class="material-icons">report problem</md-icon>
              </md-button>
              <md-button class="md-icon-button" aria-label="Share">
                <md-icon class="material-icons">share</md-icon>
              </md-button>
            </md-card-actions>
          </md-card>
        </div>
      </div>
    </section>
</md-content>

And my CSS:

body {
    background-color: #EEEEEE;
}

md-toolbar {
    z-index: 100;
}

a {
    text-decoration: none;
    color: black;
}

a:hover {
    color:#3F51B5;
}

md-card {
    width:400px;
}

I am having an issue with my site creating two scroll bars. I am using md-toolbar for my nav (which I want to be stuck to the top throughout) and md-content to hold my content. When I scroll the nav stays stuck to the top but creates an extra scroll bar. (see to the right of the pic there is two scroll bars)

Here is my index.html:

<body ng-cloak ng-app="TrooNews" ng-controller="AppController as app">

        <!--top toolbar-->
        <md-toolbar class="md-shadow-bottom-z-1">
            <div class="md-toolbar-tools">
                <md-button class="md-icon-button" ng-click="app.toggleSidenav('left')" hide-gt-md1 aria-label="Menu">
                    <md-icon>menu</md-icon>
                </md-button>
                <a href="/home"><h1>Troo News</h1></a>
                <span flex></span>
                <md-button class="md-icon-button" ng-click="" hide-gt-md1 aria-label="Search">
                    <md-icon>search</md-icon>
                </md-button>
            </div>
        </md-toolbar>

        <!--left sidenav-->
        <div layout="row" layout-fill flex>
            <md-sidenav layout="column" class="md-sidenav-left md-whiteframe-z2" md-ponent-id="left">
                <md-toolbar></md-toolbar>
                <md-content flex role="navigation">
                    <md-list>
                        <md-list-item ng-repeat="item in app.menu" ng-click="app.navigateTo(item.link)">
                            <md-icon>{{item.icon}}</md-icon>
                            <p>{{item.title}}</p>
                        </md-list-item>
                    </md-list>
                </md-content>
            </md-sidenav>
            <div layout="column" layout-fill ng-viewport></div>
        </div>

        <div ng-view class="content"></div>

    </body>

And my html for my card view:

<md-content class="container-fluid">
    <section class="content-section">
      <div layout="column" layout-align="center" ng-style="{'width': '100%'}">
        <div class='md-padding' layout="row" layout-align="center" flex-offset-sm="0" flex-offset-md="0" flex-offset-lg="0" flex-offset-gt-lg="0" layout-wrap>
          <md-card ng-repeat="article in home.articles">
            <img ng-src="{{article.imagePath}}" class="md-card-image" alt="Test image">
            <md-card-title>
              <md-card-title-text>
                <a href="/article/{{article.id}}"><span class="md-headline">{{article.title}}</span></a>
              </md-card-title-text>
            </md-card-title>
            <md-card-content>
              <p>
                {{article.text}}
              </p>
            </md-card-content>
            <md-card-actions layout="row" layout-align="end center">
              <md-button class="md-icon-button" aria-label="Report">
                <md-icon class="material-icons">report problem</md-icon>
              </md-button>
              <md-button class="md-icon-button" aria-label="Share">
                <md-icon class="material-icons">share</md-icon>
              </md-button>
            </md-card-actions>
          </md-card>
        </div>
      </div>
    </section>
</md-content>

And my CSS:

body {
    background-color: #EEEEEE;
}

md-toolbar {
    z-index: 100;
}

a {
    text-decoration: none;
    color: black;
}

a:hover {
    color:#3F51B5;
}

md-card {
    width:400px;
}
Share Improve this question asked Feb 19, 2016 at 16:48 Jess AnastasioJess Anastasio 7075 gold badges18 silver badges27 bronze badges 1
  • You probable need layout="column/row" on there body or something like that. And maybe remove the layout-fill from your main content. Add a plunkr/codepen. – kuhnroyal Commented Feb 19, 2016 at 17:02
Add a ment  | 

1 Answer 1

Reset to default 6

The toolbar sticks to the md-content not the body -> the inner scrollbar and like the website of angular material they remove the main scroll and use: body { overflow: hidden; max-width: 100%; max-height: 100%; } and keep the internal one only.

本文标签: javascriptAngular Material mdtoolbarmdcontent double scroll barStack Overflow