【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. <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:
|
<<: MySQL 5.7.16 ZIP package installation and configuration tutorial
>>: Example method of viewing IP in Linux
1. What is it? MySQL is the most popular relation...
1. Problem Sometimes when we log in to Mysql and ...
This article example shares the specific code of ...
Since I returned the Mac, my original laptop has ...
This article shares with you the detailed install...
Principle: First hide the input element, then use...
When exporting data to operations, it is inevitab...
Referring to the online information, I used cmake...
Before webpack packaging, we must ensure that the...
This article shares the specific code of vue+elem...
Table of contents Component Infrastructure Purpos...
Table of contents What is async? Why do we need a...
1. Install Apache $ sudo apt update && su...
Project Documentation Directory Div+CSS Naming Sta...
In actual work or interviews, we often encounter ...