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

Getting Started with MySQL - Concepts

1. What is it? MySQL is the most popular relation...

Vue implements verification code countdown button

This article example shares the specific code of ...

Detailed installation and use tutorial of mysql 8.0.15 under windows

This article shares with you the detailed install...

Example of using CSS3 to customize the style of input multiple-select box

Principle: First hide the input element, then use...

Mysql implements three functions for field splicing

When exporting data to operations, it is inevitab...

CentOS6.8 uses cmake to install MySQL5.7.18

Referring to the online information, I used cmake...

Webpack file packaging error exception

Before webpack packaging, we must ensure that the...

vue+element-ui implements the head navigation bar component

This article shares the specific code of vue+elem...

Example code of Vue3 encapsulated magnifying glass component

Table of contents Component Infrastructure Purpos...

Analyzing the node event loop and message queue

Table of contents What is async? Why do we need a...

CSS XTHML writing standards and common problems summary (page optimization)

Project Documentation Directory Div+CSS Naming Sta...

11 ways to remove duplicates from js arrays

In actual work or interviews, we often encounter ...