简体   繁体   English

底部有角度的粘性页脚

[英]sticky footer at bottom in angular

I am trying to place a footer at the bottom .我想在底部放置一个页脚。

在此处输入图片说明

and it is for some reason coming out like this.出于某种原因,它会像这样出现。

In index.html, I have:在 index.html 中,我有:

<main flex layout="column">
      <div>
        <div ui-view="" ></div>
      </div>
    </main>

    <footer>
      <md-toolbar class="md-hue-2 md-scroll-shrink">
        <div layout="row" layout-align="center center" flex>
          Powered by Webocity Technologies
        </div>
      </md-toolbar>

Sticky or not, this looks wrong.粘不粘,这看起来不对。 What seems wrong here and how to fix this?这里似乎有什么问题以及如何解决这个问题?

Use position:fixed;bottom:0px;使用position:fixed;bottom:0px; to display your footer at bottom在底部显示您的页脚

 footer{ position:fixed; bottom:0px; background-color:pink; width:100%; }
 <main flex layout="column"> <div> <div ui-view="" ></div> </div> </main> <footer> <md-toolbar class="md-hue-2 md-scroll-shrink"> <div layout="row" layout-align="center center" flex> Powered by Webocity Technologies </div> </md-toolbar> </footer>

There's loads of techniques to achieve this.有很多技术可以实现这一点。 One of my favourites is the one that doesn't need any fixed or absolute positioning (although totally valid) but setting the content to 100%.我最喜欢的一种是不需要任何fixedabsolute定位(虽然完全有效)但将内容设置为 100% 的。 This will only work with a fixed footer height though.不过,这只适用于固定的页脚高度。

<main flex layout="column">
  <div>
    <div ui-view="" ></div>
  </div>     
  <footer>
    <md-toolbar class="md-hue-2 md-scroll-shrink">
      <div layout="row" layout-align="center center" flex>
        Powered by Webocity Technologies
      </div>
    </md-toolbar>
  </footer>
</main>

And your CSS:还有你的 CSS:

html, body {
  height: 100%;
  margin: 0;
}
[main] {
  min-height: 100%;
}
[footer] {
  height: 150px; // for this example, can be anything
  margin-top: -150px; // exact same value as the height
}

you can try with this css class in the footer.component.scss :您可以尝试在footer.component.scss使用此 css 类:

.footer {
    bottom: 0;
    padding: 19px 15px 20px;
    position: absolute;
    right: 0;
    color:  #98a6ad;
    left: 210px;
    background-color: #ffffff;
    box-shadow: 0 0 1px rgba(50,58,70,.1);

    .footer-links {
        a {
            color:  #98a6ad;
            margin-left: 1.5rem;
            transition: all .4s;
            &:hover {
                color: #323a46;;
            }
            &:first-of-type {
                margin-left: 0;
            }
        }
    }
}

I think the important ones are bottom:0;我认为重要的是bottom:0; and position: absolute;position: absolute; , you can play around with them ,你可以和他们一起玩

And do not forget to put <footer class="footer"> in your HTML并且不要忘记将<footer class="footer">放在您的 HTML 中

BR, BR,

Julian朱利安

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

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