Creating a sticky footer using Vue.js for both mobile and desktop display views

Looking for a solution to create a sticky footer that works on both desktop and mobile views without overlapping the main content? The current code either overlaps or doesn't stick to the bottom. Seeking a responsive approach.

App.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>

Answer №1

If you're looking to make a footer sticky at the bottom of a page, there are several methods you can try. One popular option is using flexbox.

<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>

This method is both clean and efficient. Another approach you could take is to adjust the heights accordingly.

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Attempting to align input fields and spans side by side

Is there a way to properly align multiple inputs next to each other with dots in between, resembling an IPv4 address? Currently, the span appears to float in the center. How can this be resolved? It's worth noting that all elements in the image have b ...

SVG with embedded fonts failing to display properly in web browsers

Within this SVG, there are two different font types being used: SymbolMT for the mathematical expressions and Hind-Light for the text. Both fonts have been defined within the @font-face section of the SVG. The font used for the math expressions appears a ...

Steps for Deactivating HTML Links

I am facing an issue with a link button inside a <td> that needs to be disabled. It is working fine on Internet Explorer but not functioning properly in Firefox and Chrome. I have tried various methods, but nothing seems to work on Firefox (using ve ...

Troubleshooting problem with Bootstrap Modal inputs and header tags

When it comes to the button that says data-whatever="Add a recipe", I think it is causing my input placeholders to be overridden, and I'm not sure why. If I remove it, everything works but the h5 header for the new recipe will be blank. <button ...

When utilizing Vue components, the issue of "setattr" arises when trying to assign

Having recently started using Vue.js, I encountered an issue while trying to implement components. Interestingly, the code worked perfectly fine before implementing components. I'm facing an error that is proving to be quite challenging to understand ...

Failure occurred when attempting to redirect in HTML

Within my HTML code snippet, I have included a section that pertains to notifications. The main issue I am encountering is related to the redirection behavior when clicking on the "Home" link inside the designated notification container with the ID "notifi ...

The largest contentful paint is anticipating an unidentified event

My website is encountering issues with Google Pagespeed and I'm unsure of the cause. The primary bottleneck appears to be the LCP time, which Google reports as taking between 7 and 11 seconds during each test. Upon analyzing the waterfall chart, it ...

What is the process for integrating a personalized font into the <head> section of the ConvertTo-HTML?

I created a script to generate an HTML file containing information about the services on a computer, along with some additional styling. $a = "<style>" $a = $a + "BODY{background-color:peachpuff;}" $a = $a + "TABLE{border-width: 1px;border-style: so ...

Prevent background music from being manipulated

I've implemented an audio HTML element with background music for a game: <audio class="music" src="..." loop></audio> However, I have encountered an issue where upon loading the page, I am able to control the music usi ...

Is there a difference between innerHTML strings and their corresponding strings in JavaScript?

I am facing an issue with a code snippet that seems to have an unusual error. The following code is a simplified version to demonstrate the strange behavior. <html> <head> <script type = "text/javascript"> window.onload = fun ...

Running a Node.js script on an Express.js server using an HTML button

I've got an HTML button: <button id="save" type="button" onclick="save()">Save</button> and in my JavaScript code, I want it to execute something on the server side using node.js Here's what I have in mind: function save() { / ...

Optimal approach for incorporating conditional tabbed routing in Vue

My current implementation involves routing with tabs that change based on the user type, which is stored in a pinia store after authentication. This is the code I have implemented: const mappingAudienceGuard = async (to: RouteLocation): Promise<true | ...

I am attempting to design an HTML page to serve as the body of an email. Can anyone advise me on how to effectively pass it into my setBody() function while using yiiMail?

On one of my .php pages, I have the following code snippet: <html> <head></head> <body> Hi <?php echo $user['first_name'].' '.$user['last_name']?>, <br><br> To reset your ...

Triggering a specific outcome with every user interaction involving the selection of an element

How can I trigger this effect each time the user clicks on the element using jQuery? I have added a "ripple" class upon clicking, but when I click on the element for the second time, the effect does not execute because the class has already been added. Ho ...

When hovering over A, the DIV element fails to appear

I'm encountering an issue with a specific page on my website () The problem lies with a .dropdown class that is supposed to display a DIV right below the header. In the source code, you can find it underneath <-- START DROPDOWN MENU -->. When I ...

Retrieve the text located within the span tag using Selenium

When I try to inspect the element using Google Chrome, I come across the following code: <div class="form-style-abc"> <fieldset> <legend><span class="number">*</span>Search Zone</legend> I am trying to retrieve ...

Fixed position scrollable tabs with Material UI

I recently implemented material-ui scrollable tabs in my project, referencing the documentation at https://mui.com/material-ui/react-tabs/#scrollable-tabs. Here is a snippet of the code I used: <Tabs value={value} onChange={handleChange ...

HTML Tooltip with Bootstrap 4

After creating a website using Bootstrap 4 and jQuery, I encountered an issue with HTML-styled tooltips. Instead of displaying the tooltips with the correct styling, they appear to be populated using the jQuery text() function, showing the HTML as plain te ...

Issue with Caching during Javascript Minification

I Have ASP.Net MVC 3 App. Utilizing YUICompressor.Net for compressing Javascript and CSS files post build with MSBuild. The minimized javascript file is named JSMin.js and the CSS file is CssMin.css. In my master page, I reference these files as shown bel ...

Modify CSS class if user is using Internet Explorer version 10 or above

I am attempting to modify the CSS of 2 ASP controls using jQuery specifically for users accessing the site with Internet Explorer 10 or 11. This adjustment is necessary because IE10 onwards, conditional comments are no longer supported. My approach to achi ...