简体   繁体   English

角简单页脚问题(子组件中带有ngFor循环)

[英]Angular simple footer issue (with ngFor loop in child component)

I'm having a problem with trying to create a footer in an angular4 app. 我在尝试在angular4应用中创建页脚时遇到问题。 The issue seems to be if a child component loaded in the app-router is of greater height than it's parent component... The footer on the parent doesn't go to the bottom of the full page, but just to the bottom of the parent component. 问题似乎是如果在app-router中加载的子组件的高度大于其父组件的高度...父的页脚不会进入整页的底部,而只会到达页面底部父组件。

eg. 例如。

I've placed my footer at the very bottom of the app.component.html file: 我已将页脚放在app.component.html文件的最底部:

<div class="contain">
  <div id="splashbackground">
    <div class="dark-overlay">
      <app-header></app-header>
      <div class="container mt-5">
        <router-outlet></router-outlet>
      </div>
    </div>
  </div>
</div>

<app-footer></app-footer>

The footer is a very simple element: 页脚是一个非常简单的元素:

<footer style="height:150px; background-color:blue">
<h3 class="text-light mt-5">This is the app footer</h3>
</footer>

The problem is the footer doesn't go to the bottom of the total app, it goes to the bottom of the app.component.html...but if the child component being loaded in the app-router is large ie the result of an ngFor loop of many elements... then it the footer is no longer underneath the child. 问题是页脚没有到达整个应用程序的底部,而是到达了app.component.html ...的底部,但是如果在app-router中加载的子组件很大,即一个由多个元素组成的ngFor循环...那么它的页脚不再位于孩子的下面。

I can demonstrate the problem more simply by this: I add a simple component of height 3000px and bootstrap background color danger orange: 我可以通过以下方式更简单地演示该问题:我添加了一个高度为3000px的简单组件,并且引导背景颜色为危险橙色:

<div class="bg-danger" style="height: 3000px;">

</div>

I load the component via routes to go into the router outlet. 我通过路由加载组件以进入路由器出口。 The result is this: 结果是这样的:

Image of problem 问题的形象

How can I make sure the footer is at the bottom of the page? 如何确定页脚在页面底部?

EDIT: 编辑:

This CSS is attached to the .css file in the app component. 该CSS附加到应用程序组件中的.css文件。 None of the others seem to address the issue: 其他人似乎都没有解决这个问题:

#splashbackground{
    background:url('/assets/images/photo.jpg') no-repeat;
    background-size:cover;
    min-height:950px;

}

.dark-overlay{
    background-color:rgba(0,0,0,0.4);
    position:absolute;
    top:0;
    left:0;
    width:100%;
    min-height:952px;
}

Outside attached to other .css files there's these, but none of them really deal with positioning of the card elements or anything. 除了附加到其他.css文件之外,还有其他文件,但是它们中的任何一个都不能真正处理卡片元素或其他任何元素的位置。 What can I add to the footer element to ensure it will be at the bottom? 我可以在页脚元素中添加什么以确保它位于底部?

.center-block {  
  display: block;  
  margin-right: auto;  
  margin-left: auto;  
}  

.clickable{
    cursor: pointer;
}

.borderThin{
    border: 1px gray inset;
    border-radius: 15px;

}

.vertical-align {
    position:relative;
    top:50%;

}


.card-img-left {
  border-bottom-left-radius: calc(.25rem - 1px);
  border-top-left-radius: calc(.25rem - 1px);
  float: left;
  padding-right: 1em;
  margin-bottom: -1.25em;
}

.panelTheme {
    background-color: #222;
     color:#999;
     border-radius: 5px;
}


/*Image Insertion*/

.customClass {
    background-color: #222;
    border-radius: 5px;
    margin:5px;
    width: 500px;
}

.customClass .img-ul-upload {
    background-color: #222 !important;
}

.customClass .img-ul-clear {
    background-color: #222 !important;
}

.customClass .img-ul-drag-box-msg {
    color: purple !important;
}

.customClass .img-ul-container {
    background-color: #222 !important;
}



/*Image Insertion*/

/* Ensure that all of the zero offsets are available - recent SASS version did not include .col-sm-offset-0 */
@media (min-width: 768px) {
    .col-sm-offset-0,
    .col-md-offset-0,
    .col-lg-offset-0 {
        margin-left: 0;
    }
}

.modal-content{

    background-color: #222;
    border-color: #222;
    border-radius: 0;
}


.modal-header{

    border-bottom: 0px !important;
}

.modal-backdrop{
    background-color: red;
}
.customClass {
    background-color: #D21C1C;
    border-radius: 5px;
    margin:auto;
    width: 50%;
}

.customClass .img-ul-upload {
    background-color: #222 !important;
}

.customClass .img-ul-clear {
    background-color: #222 !important;
}

.customClass .img-ul-drag-box-msg {
    color: purple !important;
}

.customClass .img-ul-container {
    background-color: #222 !important;
}

Solved! 解决了!

The issue seems to have been how the divs were organised in the app-component.html: Going from: 问题似乎是在app-component.html中div的组织方式:来自:

<div class="contain">
  <div id="splashbackground">
    <div class="dark-overlay">
      <app-header></app-header>
      <div class="container mt-5">
        <router-outlet></router-outlet>
      </div>
    </div>
  </div>
</div>

<app-footer></app-footer>

to this: 对此:

<div id="splashbackground">
  <div class="dark-overlay">
    <app-header></app-header>
    <div class="container mt-5">
      <router-outlet></router-outlet>
    </div>
    <app-footer></app-footer>
  </div>
</div>

fixed the issue. 解决了这个问题。

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

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