Example of Vue implementing fixed bottom component

Example of Vue implementing fixed bottom component

【Effect】

【Implementation method】

<template>
  <div id="app">
    <div class="main">
      <img alt="Vue logo" src="./assets/logo.png">
      <HelloWorld msg="Welcome to Your Vue.js App"/>
      <img alt="Vue logo" src="./assets/logo.png">
    </div>
    <div class="footer">This is a button fixed at the bottom</div>
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components:
    HelloWorld
  }
}
</script>

<style>
:root{
  --footer-height: 50px;
}
body {
  padding: 0;
  margin: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.main{
  padding-bottom: var(--footer-height);
  overflow-y: auto;
}
.footer{
  position: fixed;
  bottom: 0;
  width: 100%;
  line-height: var(--footer-height);
  background: #42b983;
  color: #fff;
}
</style>

[Add requirements] Add an A logic. When the A logic is met, the bottom button will not be displayed, but it will be displayed in other cases.
Add a Bool value (isShow) to determine whether the bottom button is displayed. The specific code is as follows:

<template>
  <div id="app">
    <div class="main">
      <img alt="Vue logo" src="./assets/logo.png">
      <HelloWorld msg="Welcome to Your Vue.js App"/>
      <img alt="Vue logo" src="./assets/logo.png">
    </div>
    <div class="footer" v-if='isShow'>
      <div class="footer-content">This is a button fixed at the bottom</div>
    </div>
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components:
    HelloWorld
  },
  data() {
    return {
      isShow: true
    }
  },
}
</script>

<style>
:root{
  --footer-height: 50px;
}
body {
  padding: 0;
  margin: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.main {
  overflow-y: auto;
}
.footer {
  height: var(--footer-height);
}
.footer-content {
  position: fixed;
  bottom: 0;
  width: 100%;
  line-height: var(--footer-height);
  background: #42b983;
  color: #fff;
}
</style>

This concludes this article about the example of implementing a fixed bottom component with Vue. For more relevant Vue fixed bottom content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • The bottom navigation of the mobile terminal is fixed with vue-router to realize the component switching function

<<:  MySQL 5.7.16 ZIP package installation and configuration tutorial

>>:  Example method of viewing IP in Linux

Recommend

mysql 8.0.19 win10 quick installation tutorial

This tutorial shares the installation tutorial of...

Three useful codes to make visitors remember your website

Three useful codes to help visitors remember your...

Example of how to set up a Linux system to automatically run a script at startup

Preface Hello everyone, I am Liang Xu. At work, w...

Summary of practical skills commonly used in Vue projects

Table of contents Preface 1. Use $attrs and $list...

Detailed installation and use tutorial of mysql 8.0.15 under windows

This article shares with you the detailed install...

How to install multiple mysql5.7.19 (tar.gz) files under Linux

For the beginner's first installation of MySQ...

3 Tips You Must Know When Learning JavaScript

Table of contents 1. The magical extension operat...

Vue plugin error: Vue.js is detected on this page. Problem solved

Vue plugin reports an error: Vue.js is detected o...

Boundary and range description of between in mysql

mysql between boundary range The range of between...

How to set up Spring Boot using Docker layered packaging

The Spring Boot project uses docker containers, j...

Useful codes for web page creation

<br />How can I remove the scroll bar on the...