【问题标题】:Sticky footer in vuejs application [duplicate]vuejs应用程序中的粘性页脚[重复]
【发布时间】:2018-05-09 17:06:23
【问题描述】:

我正在努力在我的 vuejs 应用程序中制作粘性页脚。

vuejs 和其他类似的框架要求模板中存在根元素。

但这使得使用 Flex 添加粘性页脚变得困难。

没有根元素:

<div class="content">
  <h1>Sticky Footer with Flexbox</h1>
  <p>
    <button id="add">Add Content</button>
  </p>
</div>

<footer class="footer">
  Footer
</footer>

一切都适用,但对于根元素,它不起作用。

<div>
  <div class="content">
    <h1>Sticky Footer with Flexbox</h1>
    <p>
      <button id="add">Add Content</button>
    </p>
  </div>

  <footer class="footer">
    Footer
  </footer>
</div>

由于不能删除根元素,请问如何更新 css 以使用根元素?

JsFiddle

【问题讨论】:

  • 只需将body 规则更改为body &gt; div {...}

标签: html css vue.js flexbox


【解决方案1】:

您可以将id 设置为外部div(例如id="app")并使用您为body 定义的css 规则:

<div id="app">
  ...
</div>
html, body {
  height: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

https://jsfiddle.net/Low3fbs1/4/

【讨论】:

  • 效果很好!!
猜你喜欢
  • 2018-08-17
  • 2019-02-11
  • 2014-03-15
  • 2015-06-10
  • 2014-08-13
  • 1970-01-01
  • 1970-01-01
  • 2013-02-23
  • 2015-05-06
相关资源
最近更新 更多