What is the best way to ensure my Vue webpage completely fills the viewport?

I'm currently working on a demo web application created with Vue 3, Vue Router, and Bootstrap using Vue CLI. My main issue is that the webpage does not extend to fill the entire height of the browser window.

My attempt to use bootstrap and set vh-100 on the top-level div did not achieve the desired result - instead of taking up the full visible viewport height, the content's minimum height was being matched vertically.

Any suggestions on how I can ensure my app layout adheres to Bootstrap's vh-100 property?

App.vue

    <template>
  <router-view/>
</template>

<script>

export default {
  name: "App"
}
</script>

LoginPage.vue

<template>
  <div class="vh-100 container" id="app">
    <div class="row vh-25">
      <div class="image-container row justify-content-center align-items-center">
        <img src="../assets/images/pic.png" alt="picture">
      </div>
    </div>
    <div class="row vh-75">
      <EmailForm/>
    </div>
  </div>
</template>

<script>
import EmailForm from '@/components/EmailForm.vue'; // @ is an alias to /src

export default {
  components: {
    EmailForm,
  }
}
</script>

<style>
.container {
  margin: 0;
  background: url(~@/assets/images/background_pic.jpg) repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
.image-container {
  position: relative;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  text-align: center;
}

img {
  padding: 0;
  display: block;
  margin: 0 auto;
  max-height: 60%;
  max-width: 60%;
}
</style>

Answer №1

There are numerous strategies to achieve this goal. In Vue, it is common practice to designate the #app as the top-level element and set a minimum height property there.

#app {
  min-height: 100vh;
}

Alternatively, you could make the .container element have a fixed position that covers the entire viewport.

.container {
  position: fixed;
  top:0;
  right: 0;
  bottom: 0;
  left: 0;
}

The approach you take should align with your specific requirements and objectives.

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

The v-bind value remains static even as the data in Vue.js updates

I created a function called changeActive that is supposed to update the value of an active boolean. Interestingly, after checking the console log, I observed that the active value changes but for some reason, the updated value is not being passed in the ...

Enhancing react-input-range with unique Custom Arrow heads

I'm currently working with react-input-range to create a price range slider. While I've managed to customize the CSS of the range slider, I now need to figure out how to add arrow heads inside the circles as shown below: https://i.sstatic.net/pm ...

How can I use Bootstrap and PHP to style future posts in separate rows on a website?

I am attempting to design a categories navigation menu using Bootstrap 5. It consists of two columns, the first displaying featured posts and the second showing 5 recent posts. Here is an example of what I have tried, but it didn't work as expected b ...

Issue with Bootstrap v3.3.7 panel not collapsing as expected following height adjustment

Utilizing bootstrap 3.3.7 panels, I encountered an issue when trying to slide up the panel using the icon. The panel would not hide properly once the panel height was set, resulting in only the panel content body sliding up. Here is an example: $(&apo ...

Customizing event colors in Full Calendar

My interactive calendar is created using : $('#calendar').fullCalendar({ height: 300, //............. events: jsonData, month: firstMonth }) I am looking to dynamically change the color of an event based on certain conditions ...

Is it necessary in Vue 3 to include the entire object structure when setting up a reactive value?

If I need to establish an empty value in my Pinia store to store the current subscription model the user is viewing, it should be null if the user is not on a subscription detail page. Process: When the user clicks on a link to view subscription details f ...

Importing or loading a JavaScript file in Vue.js is a crucial step

I'm in need of some assistance. I've been attempting to load my javascript file and listen for changes on the checkbox when it's clicked to show or hide a password. However, I can't seem to get it to work. I've tried everything I c ...

Is there a way to prevent my menu from switching to mobile view if it can fully fit within the menu area on the device?

I've implemented a code on my website that changes the menu to "mobile" when the device screen resolution is less than 1024px. However, I noticed that the menu still displays correctly even when the device is around 800px. Is there a way to adjust thi ...

Tips for incorporating multiple inputs within a foreach loop

My challenge involves dealing with two input fields that allow users to add multiple records in a single form submission. I am currently using a foreach loop to iterate through one of the inputs and retrieve the value, but now I need a way to loop through ...

After checking the checkbox to add a class, I then need to remove that class without having to interact with the entire document

When I click on a checkbox, an animation is added to a div. However, I am struggling to remove this animation unless I click elsewhere on the document. The goal is for the checkbox to both add and remove the class. JS $('#inOrder').click(functi ...

Accordion-style elements arranged in a grid format, smoothly displacing surrounding content

I am facing an issue with a grid of accordions, as demonstrated in the codesandbox linked below. The problem arises when I open one accordion, causing all the accordions in the row below to shift down. Ideally, only the accordion directly below should be p ...

A guide to loading CSS and JavaScript files asynchronously

Is it possible to use loadCSS (https://github.com/filamentgroup/loadCSS/blob/master/README.md) to allow the browser to asynchronously load CSS and JavaScript? This is what I currently have in my head tag: <link rel="preload" href="http://zoidstudios. ...

A guide to transforming a string into a numerical value using Vue

When this code is executed, it will display the following string: Pressure 770.3157279 mm <div class="info">Pressure {{info.main.pressure * 0.750064}} mm </div> If you want to convert the number to an integer and achieve the output: Pressure ...

What might be causing the issue of not being able to access req.body using multer?

In my application built using vue, users have the ability to upload files along with some data to my node backend. Once the user submits the form, the following function is executed: methods: { buttonOK () { const formData = new FormData() ...

what is the smallest browser width required to show the navigation bar collapse button?

Is it possible to adjust the browser width in order to display the collapse button for a navigation bar in Bootstrap? I believe media queries could assist with this, but I am unsure how to specify the minimum width of the browser window. ...

Creating a form with an input field and an image side by side in HTML

I've been attempting to display an HTML input element and an SVG image on the same line without success. I've tried various solutions from stackoverflow, but none seem to work for me. Here's my current HTML code: <div id = "inline_eleme ...

Another inquiry about bootstrap: Adjusting vertical height only if content does not overflow

My current setup is as follows: <div class="container px-0"> <nav class="..."> </nav> <div class="row px-3"> ...content </div> <div class="row footer-spacer&q ...

Utilizing the Mouse Hover feature to target various <div id> elements within a single Vue.js function

I have created two div IDs in an HTML file where I have specified the mouseover property. <div id="app"> <img class="img-responsive img-full" v-bind:src="imgData" @mouseover="imgData = imgData_1"> </div> <div id="app1"> <img cl ...

What methods can I use to accomplish the transformation of superimposed images?

Struggling with transforming a content box on my webpage. I have a div containing three overlapping images positioned using Grid, and I want to scale one of them to fill the entire div when scrolled over. While I managed to achieve this effect, I'm un ...

The website using WordPress WooCommerce and WP Touch is currently not appearing mobile-friendly. Additionally, there seems to be an issue with the carousel as the images are not displaying

Can someone help me with these issues I am facing on my website? Why does my CSS reset after using certain code? How can I make products show in the middle on mobile, other than on the homepage? Website URL : (www.thevapeboys.co.uk) I have a WordPre ...