vuejs: липкий нижний колонтитул в представлении мобильного телефона и дисплея - PullRequest
0 голосов
/ 14 января 2020

Как создать липкий нижний колонтитул на рабочем столе, а также мобильный вид? Следующий код перекрывает основной контент. При установке в нижний колонтитул position: relative; он не перекрывается, но и не прилипает к основанию. Мне нужно адаптивное решение.

Приложение. vue:

<template>
  <div id="app">
    <NavbarComponent/>
    <router-view/>
    <FooterComponent/>
  </div>
</template>

<script>
import NavbarComponent from "./components/Navbar" 
import FooterComponent from "./components/FooterComponent"

export default {
  name: "App",
  components: {
    NavbarComponent,
    FooterComponent
  }
}

</script>
<style>

    body {
      min-height: 100vh;
      position: relative;
      margin: 0;
    }

</style>

FooterComponent. vue:

<template>
  <footer>
    <p class="text-center">Some random text for the footer.</p>
  </footer>
</template>

<script></script>

<style scoped>
  footer {
    color: white;
    background-color: #003459;
    position: absolute;
    bottom: 0;
    width: 100%;
    margin-top: 50px;
  }
</style>

1 Ответ

0 голосов
/ 14 января 2020

У нас есть много способов сделать нижний колонтитул липким внизу. Вы можете попробовать использовать flex.

<body>
 <div class='container'></div>
 <div class='footer'></div>
</body>
<style>
html, body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
}
.container {
  flex: 1; //or 1 0 auto
}
.footer {
  flex-shrink: 0;
}
</style>

Очень чисто и быстро. Или вы можете попробовать с уменьшенной высотой ...

.container {
  min-height: calc(100vh - 80px);
}
.footer {
  height: 60px;
}
...