简体   繁体   English

如何使可滚动div隐藏在标题和子标题的后面?

[英]How can I make a scrollable div hide behind my header and sub-header?

I have a header, sub-header and a long list of information that is vertically scrollable in my app. 我有一个标题,子标题和一长串信息,这些信息可以在我的应用程序中垂直滚动。 Currently, the list of information hides behind the header when it is scrolled upwards, but it goes over the sub-header. 当前,信息列表在向上滚动时隐藏在标题的后面,但是它超过了子标题。

I've tried changing the sub-header to be absolutely positioned, and I've tried adding a z-index to both the scrollable div and sub-header, but neither have worked. 我尝试将子标题更改为绝对位置,并尝试将z-index添加到可滚动div和子标题中,但都没有起作用。 I've also tried putting the sub-header inside ion-content, but then it scrolls with the list information too. 我也尝试过将子标题放入ion-content中,但随后它也会与列表信息一起滚动。

How can I get the scrollable content to go behind both the header and the sub-header? 如何获取可滚动内容同时放在标题子标题的后面?

Additional information can be provided if needed. 如果需要,可以提供其他信息。

HTML HTML

<ion-view hide-nav-bar="false">

  <div class="sub-header">
    <span class="name">{{ user.name }}</span>
  </div>

  <ion-content has-header="true">
    <div class="messages">
      <div class="message" ng-repeat="msg in messages">
        <div>{{ msg.date }}</div>
        <div>{{ msg.text }}</div>
        <hr ng-show="!$last"/>
      </div>
    </div>
  </ion-content>

</ion-view>

I got it to do what I wanted by adding the following styles to the sub-header: 我通过在子标题中添加以下样式来完成我想要的工作:

.sub-header {
  background-color: #fff;
  position: relative;
  top: 50px;
  z-index: 1;
}

The trick was adding background-color: #fff . 技巧是添加background-color: #fff

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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