material icon indicating copy to clipboard operation
material copied to clipboard

md-subheader fills width of viewport when inside md-content

Open rwestonbutler opened this issue 11 years ago • 8 comments

The title pretty much explains it. I have two md-contents on a page, one flex 33 and one flex 66. I expect the md-subheader to be contained within it's parent div. You can observe in this plunkr: http://plnkr.co/edit/HbKw4zJQhFzbo6Aa7qYn?p=preview

rwestonbutler avatar May 27 '15 20:05 rwestonbutler

I can confirm this issue too. Also the quirk below, it seems to pop out unusually (in addition to what @rwestonbutler described:

quirk

Implementation below:

'''

        <md-toolbar class="demo-toolbar">
      <div class="md-toolbar-tools">
        <h3>
          <span>My Tasks</span>
        </h3>
      </div>
  </md-toolbar>

  <md-content style="height:300px">
    <md-section>
        <md-subheader class="md-primary">Need Marking</md-subheader>
    <!-- Need marking List -->
          <md-list>

          <md-list-item class="md-3-line" ng-repeat="item in todos">
            <md-icon md-svg-icon="{{item.ico}}" alt="{{item.who}}" class="md-avatar">
            </md-icon>
            <div class="md-list-item-text">
              <h3>{{item.title}}</h3>
              <h4>{{item.publisher}}</h4>
              <p>
                {{item.description}}
              </p>
            </div>
            <md-divider inset=""></md-divider>
          </md-list-item>

        </md-list>

    </md-section>


            <md-section>
        <md-subheader class="md-primary">Tests to go</md-subheader>
    <!-- Need to do List -->
          <md-list>

          <md-list-item class="md-3-line" ng-repeat="item in todos">
            <md-icon md-svg-icon="{{item.ico}}" alt="{{item.who}}" class="md-avatar">
            </md-icon>
            <div class="md-list-item-text">
              <h3>{{item.title}}</h3>
              <h4>{{item.publisher}}</h4>
              <p>
                {{item.description}}
              </p>
            </div>
            <md-divider inset=""></md-divider>
          </md-list-item>

        </md-list>

    </md-section>

  </md-content>

</md-section>
<md-section flex class="demo-container">

  <md-toolbar class="demo-toolbar">
      <div class="md-toolbar-tools">
        <h3>
          <span>My Tasks</span>
        </h3>
      </div>
  </md-toolbar>

  <md-content style="height:300px">

    <md-section>
        <md-subheader class="md-primary">Teaching</md-subheader>
    <!-- Teaching List -->
          <md-list>

          <md-list-item class="md-3-line" ng-repeat="item in todos">
            <md-icon md-svg-icon="{{item.ico}}" alt="{{item.who}}" class="md-avatar">
            </md-icon>
            <div class="md-list-item-text">
              <h3>{{item.title}}</h3>
              <h4>{{item.publisher}}</h4>
              <p>
                {{item.description}}
              </p>
            </div>
            <md-divider inset=""></md-divider>
          </md-list-item>

        </md-list>

    </md-section>


    <md-section>
        <md-subheader class="md-primary">Learning</md-subheader>
    <!-- Learning List -->
          <md-list>

          <md-list-item class="md-3-line" ng-repeat="item in todos">
            <md-icon md-svg-icon="{{item.ico}}" alt="{{item.who}}" class="md-avatar">
            </md-icon>
            <div class="md-list-item-text">
              <h3>{{item.title}}</h3>
              <h4>{{item.publisher}}</h4>
              <p>
                {{item.description}}
              </p>
            </div>
            <md-divider inset=""></md-divider>
          </md-list-item>

        </md-list>

    </md-section>

  </md-content>

</md-section>

'''

viztastic avatar Jun 11 '15 04:06 viztastic

+1 , for me , happens only on chorme

ricardobfa avatar Jun 12 '15 20:06 ricardobfa

By design, a sticky component like mdSubheader will be placed with absolute positioning outside the closest parent mdContent. The behaviour you're describing is counter-intuitive and confusing, but (I believe) to spec.

The solution is to wrap the mdContent in a relatively positioned container.

joshdmiller avatar Jun 15 '15 18:06 joshdmiller

@joshdmiller is correct; simply surrounding your <md-content> with a <div style="position: relative"> will fix this issue. With such a simple workaround, I'm not sure we can provide a better/cleaner solution. @ThomasBurleson can you chime in?

@viztastic Can you elaborate on your phrase "pop out unusually" and perhaps provide a demo? :-)

topherfangio avatar Aug 15 '15 22:08 topherfangio

I just pushed a PR (#4276) which I think might fix this. I will update once it hits master and see if you can retest.

topherfangio avatar Aug 21 '15 19:08 topherfangio

@rwestonbutler @viztastic The original plunkr now seems to be working correctly (it loads material's master branch from bower).

Can one of you two please confirm and we will close?

topherfangio avatar Aug 27 '15 13:08 topherfangio

LGTM - http://plnkr.co/edit/1hpQBs9xQPQNjjpE1iYo?p=preview

ThomasBurleson avatar Aug 27 '15 18:08 ThomasBurleson

looks good. Thanks guys!

rwestonbutler avatar Aug 27 '15 20:08 rwestonbutler