Resizing the Vue page to fit the viewport and using Flexbox to anchor the footer to the bottom

My Vue.js page structure consists of a navigation bar, main body content, and a footer:

<template>
  <div class="flex_container">
    <div class="container_navigation">
      <nav-bar />
    </div>
    <div class="container_body">
      <h1>{{ data.pages.home.heading }}</h1>
      <p>{{ data.pages.home.about}}</p>
    </div>
    <div class="container_footer">
      <pagefooter />
    </div>
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
import NavBar from '...';
import Pagefooter from '...';
import siteData from '...';

export default Vue.extend({
  components: {
    NavBar,
    Pagefooter
  },
  mounted(){  },
  computed: {  },
  data(){
    return{
      data: siteData
    }
  }
});
</script>

<style scoped>
.flex_container{ 
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1px;
  margin: 1px;
  width: 100%;
}

.container_navigation{
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 1px;
  margin: 1px;
  width: 100%;
}

.container_body{
  flex-direction: column;
  padding: 2%;
  margin: auto;
  width: 100%;
}

.container_footer{
  flex-direction: row;
  padding: 1px;
  margin: 1px;
  width: 100%;
}
</style>

While trying various CSS tricks recommended in the complete guide to flexbox, I am facing two layout issues:

(i) The webpage does not stretch to fill the entire viewport. (ii) The footer is not sticking to the bottom of the page.

Despite ongoing styling adjustments, there is still a noticeable issue with the alignment of the footer as shown in the screenshot below:

https://i.sstatic.net/gNUWP.png

Answer №1

The feedback on this question was somewhat accurate, however, it did not pertain specifically to vue/nuxt!

To resolve the issue, the initial step was to make changes to the layouts/default.vue file by:

<template>
  <div class="nuxt_container">
    <Nuxt />
  </div>
</template>

<style>
html {
  font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI',  Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  word-spacing: 1px;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
}

.nuxt_container{
  height: 100vh;
}

</style>

An important detail here is to ensure that height: 100vh; is set.

The second adjustment involved applying the layout to the pages... such as in pages/index.vue

export default Vue.extend({
  layout: 'default',
  components: {  },
  mounted(){   },
  computed: {  },
  data(){
    return{
    }
  }
});
</script>

Include layout: 'default' (or the name of your layout file) in order to specify its usage!

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

endless update cycle in Vue

I'm currently working on developing a custom component. And I have an idea of how I want to use it: let app = new Vue({ el:'#app', template:` <tab> <tab-item name='1'> <h1> This is tab item 1& ...

"Enjoying a table header that scrolls freely with autoscroll feature

Resolved - http://jsfiddle.net/CrSpu/11704/ I'm facing an issue with a table that has autoscroll functionality. I am looking to freeze the header of the table when automatic scrolling occurs, or you can test it out using my code pen. I'm uncer ...

The width of table cells expands even when using the box-sizing property set to border-box

Whenever I click the View button, I want to apply padding to the cells in my table. However, this action also increases the width of the cell. Despite researching various solutions like those found in this question, this one, and this post, I still encount ...

What is the best way to design a group of radio buttons with corresponding labels at the top

I'm looking to create a structure like this in HTML: https://i.sstatic.net/wLcZs.png Does anyone know how I can achieve this layout so that the labels are aligned properly with the radio buttons? My main challenge is getting the horizontal labels ab ...

tips for expanding the size of your images

Hey there, I'm looking for some help with the code below. I need to increase the width of the images and remove the border of the slider div which is currently showing a white border that I want to get rid of. I am using JavaScript to display the imag ...

Utilize Vite 2 to import the Monaco Editor into your project

After setting up my Vite 2 project with monaco-editor as a dependency, I encountered an issue where it says that the workers are not imported. editorSimpleWorker.js:454 Uncaught (in promise) Error: Unexpected usage at EditorSimpleWorker.loadForeignModu ...

How to Achieve a Fixed Bottom Footer in Ember Framework

Hello, I am working on an Ember application and trying to implement a Sticky Footer feature. I followed a tutorial on Sticky Footer On CSS-Tricks which worked for me previously, but it seems to not work with Ember. Here is my CSS code: .mainFooter { ...

Issue with content overlapping when hamburger icon is tapped on mobile device

When the hamburger menu is pressed on smaller screens, I want my navbar to cover the entire screen. To achieve this, I included the .push class in my code (see the jQuery and CSS) to trigger when the .navbar-toggle-icon is pushed. However, after implemen ...

Troubleshooting Data Retrieval Issue on Page Refresh in Vue.js with Firebase

Currently working on developing a profile page for users. I have already created login and register pages, and integrated Firebase auth into the project. However, I am facing an issue where the user data is not displayed when the profile page is reloaded ...

Vue.js failing to update when object property changes

<v-container class="text-center hyp-container pa-4"> <v-row> <button @click="toggleForm">Create new target</button> </v-row> <v-row> <v-dialog v-model="showConfirmDelet ...

Encountered a problem while attempting to execute npm run dev on laravel combined with inertia in a

It seems that the issue persists despite multiple attempts to fix it. From clearing cache to reinstalling npm and deleting node-modules and package-lock, nothing has resolved this error so far. Good day! Despite my efforts to troubleshoot by clearing cach ...

The property was computed but cannot be set - specifically for a toggle component

I am currently working on developing a switch toggle component in Vue that includes a v-model and @updated. However, I am encountering difficulties when trying to update the model once the user toggles the switch. Initially, I faced an issue regarding muta ...

Guide for positioning buttons in front of an image using HTML and CSS

I need assistance placing buttons in specific positions above an image carousel using HTML and CSS code. Despite researching various resources, I am unable to resolve this issue. This is the HTML implementation: <!-- Image where buttons should be placed ...

Merging two arrays by their corresponding IDs and indexes

Within my current project, I am working with two arrays. The first array, arr1, contains a questionID property that I need to use to combine it with arr2 based on the condition where arr1 questionID equals arr2 index. For example, if arr1 questionID is 1, ...

Conceal the scrollbar while navigating within the parent container

I'm currently working on implementing a parallax header on my WordPress site using the Divi theme. Below is the code I have so far: <div class="parallax"> <div class="parralax__layer parallax__layer--back"> <img src="https://crisp ...

I am looking to implement user authentication using firebase, however, the sign-in page is currently allowing invalid inputs

<script> function save_user() { const uid = document.getElementById('user_id'); const userpwd = document.getElementById('user_pwd'); const btnregister=document.getElementById('btn-acti ...

Nuxt 3 Navigation: dynamic routes showing 404 error

I am currently attempting to create a dynamic link using Nuxt3 ("3.0.0-rc.3") and I am encountering issues with reaching the dynamic slug url. Despite following the instructions on this page, it does not seem to be functioning as expected: https: ...

Customizing Thickness for Tab Labels in MUI 5

I have been trying to adjust the thickness of the label inside a tab using MUI 5, but so far I haven't had success. Here is what I have attempted: interface TabPanelProps { children?: React.ReactNode; index: number; value: number; } funct ...

Centering content within a <th> tag

Hey there, I'm currently facing an issue with aligning a div inside another one. To illustrate the problem, I've set up a small fiddle which you can check out here: https://jsfiddle.net/jpq7xzoz/ The challenge arises when using the jQuery table ...

What is the process for converting x and y coordinates to align with a fixed display?

When I make an API call, I am receiving X and Y coordinates in the following format: x: "-0.0120956897735595703" y: "0.147876381874084473" To display these coordinates on my minimap images, I have set their display to be absolute. The "left" and "top" pr ...