简体   繁体   中英

Angular Material md-subheader not sticky

I'm using several <md-subheader> s on my page, but they are not sticking to the top when the user scrolls down (like in the demo ).

Any ideas? Maybe my layout is causing the problem?

<body>
  <div>
    <md-toolbar>
    <div>
      <md-sidenav>
      <md-content>
        <section>
          <md-subheader>
...

Here is a codepen .


Based on another question I had , just adding layout="column" layout-fill to the top div works, too.

The section s fit inside md-content . So, when you scroll, you don't scroll inside md-content . In order for the stickiness to work, you should scroll inside of md-content .

I gave a height of 500px to md-content so that you can see the effect.

<md-content layout="column" layout-padding flex style="height: 500px;">

    <!-- Report content -->

    <section ng-repeat="i in [1,2,3,4,5]">

Here is the working codepen .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM