Issues with Vue-Router Flexbox causing scrolling problems or no scrolling functionality

Having trouble with a component containing a router-view that displays a flexbox? The issue arises when the flexboxes do not scroll properly, cutting off the last element in the v-for loop. Various solutions have been attempted, but none seem to fully resolve the problem.

Below is the template and relevant styles for the router view:

<template>
    <div class="modal" ref="modal">
        <div class="modalcontent" ref="content">
            <p class="goback" @click="closeAnimation" ref="goback">←</p>
            <div class="title">
                <h1>Questions & Answers</h1>
            </div>
            <div class="routerview">
                <router-view :posts="posts" v-slot="{ Component }">
                    <transition name="slide-in" mode="out-in">
                        <component :is="Component" />
                    </transition>
                </router-view>
            </div>
        </div>
    </div>
</template>



<style>

.routerview {
    position: relative;
    width: 80%;
    margin: auto;
    overflow-y: scroll;
    left: 0;
    right: 0;
    outline: 10px red;
}

</style>

And here are the styles for the flexbox:

<template>
    <div class="container">
        <div class="flex-container" ref="flexcontainer">
                <div class="question" v-for="post in posts" :key="post._id" @click="this.$router.push(`/forum/question/${post._id}`)">
                    <h1 class="qTitle">{{ post.title }}</h1>
                    <p class="qReplyAmt">{{ post.replies.length }} repl<span v-if="!plural(post.replies.length)">y</span><span v-else>ies</span></p>
            </div>
        </div>
        <p>You've reached the end</p>
    </div>
</template>


<style scoped>
.question {
    width: 98%;
    height: fit-content;
    min-height: 0;
    background-color: whitesmoke;
    border-radius: 10px;
    padding: 10px 10px 2px 15px;
    cursor: pointer;
    transition: all 200ms ease-out;
}

.question:hover {
    background-color: rgb(255, 107, 107);
    color: white;
}

.qTitle {
    display: block;
}

.qReplyAmt {
    position: relative;
    top: -5px;
}

.flex-container {
    display: flex;
    align-items: center;
    flex-direction: column-reverse;
    width: 100%;
    gap: 15px;
    flex: 1;
}
</style>

Tried solutions include:

  • Setting a height on .container, .routerview, .flex-container
  • Setting overflow-y to auto & scroll on .container, .routerview, .flex-container
  • Exploring various other answers to fix the scrolling issue with flexboxes

Answer №1

Successfully resolved the issue by updating the styles as follows:

.flex-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: column-reverse;
    width: 100%;
    gap: 15px;
    flex: 1;
    margin-top: auto;
    margin-bottom: 125px;
}

.container {
    overflow-y: scroll;
    height: 100vh;
}

Incorporated the .container styles for proper scrolling functionality and included margin-bottom: 125px; to resolve the issue of the last item getting cut off.

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

Designing websites using elements that float to the right in a responsive manner

Responsive design often uses percentage width and absolute positioning to adjust to different screen sizes on various devices. What if we explore the use of the float right CSS style, which is not as commonly used but offers high cross-browser compatibilit ...

Can someone help me transform this LESS code into SCSS?

Currently, I am working on adapting a theme from [www.bootswatch.com][1] that is originally in less format to scss for my rails application. Although I am not well-versed in either SCSS or LESS, I have been researching the variances and have identified so ...

Displaying cards horizontally on desktop and vertically on mobile using CSS

Context and Issue I am currently working on this specific page, with a focus on the "Top Artists" section. Desired Outcome: When viewed from a laptop, I aim for the cards to be displayed as vertical rectangles, where the ranking is at the top, followe ...

As I hover over this bootstrap button with the class "btn-info", its background color fades away

Can anyone explain why this button loses its background color when I hover over it? Here is the code for the button: <nav class="navbar navbar-default navbar-static-top" role="navigation"> <div class="container"> <button type="butt ...

Enhance tables by incorporating sorting arrows onto <th> elements, reminiscent of table sorter

How can I add double arrows (up and down) to my table similar to the functionality in the tablesorter plugin? When I use this fiddle, none of the arrows appear despite working fine on my original table. I attempted the following: $("table th").addClass( ...

The issue arises when attempting to apply styling to a table row using the tr:hover CSS selector in IE 8, specifically when hovering over an input text field nested within div and td elements

When hovering over the row (tr), the tr:hover rule is being applied. However, when hovering over the child text content of the tr input, the tr:hover rule is not being applied. This issue is specific to IE-8. Can anyone help me identify the root cause? N ...

Libraries that provide webkit support for all browsers

Looking for a library that supports CSS webkit across various browsers, including older ones like ie6. Preferably written in JavaScript. Any recommendations? ...

Building a multi-form application with HTML5 validation and Vue.js

I am working on a vue.js form that consists of multiple steps and requires HTML5 validation to be simplified. Here is a snippet of the code: <template> <div> <div v-if="activeForm === 1"> <h2> ...

The sidebar is refusing to stick. I've exhausted all resources on Stack Overflow trying to fix it

Having issues with the sticky sidebar on my website, I've tried solutions from various Stack Overflow threads: Understanding "position: sticky;" property Fix for position:sticky not working Implementing sticky sidebar when scrolling down/up The is ...

Personalized details upon logging in

I have a vision for a website where users can login, register, and access a list of their own customers with functionalities specific to each user (such as sending an SMS from their registered phone number). I've found tutorials on how to implement th ...

Utilizing React with Emotion to Customize Font Sizes

In my React app, I am using emotion to style and display the formula for compound interest. Within my render() method, I am returning the following: <div css ={equation}> <p> P (1 +</p> <p css={fraction}> <span classNa ...

The process of downloading a webpage onto a computer is not completely successful

I recently created a webpage on WIX and attempted to download it using CTRL+S. However, when I loaded the site from my computer, certain elements were not functioning properly. Is there a specific piece of code that is missing when saving the webpage in th ...

The art of VueJs dynamic template rendering

One common issue arises when appending HTML to the DOM that includes other Vue components. You have the option to insert them as plain HTML or render them within the HTML, but connecting them to the same parent can be tricky as they behave as separate inst ...

Create space between two table-cell div elements by adjusting the margin

Two buttons need to be displayed in one line with vertically aligned text, so I used display: table-cell. However, the two divs are sticking together and margin is not working. Is there a way to separate them? Check out the code here: http://jsfiddle.net/ ...

Steps to resolve transition zoom issues with images

I'm having trouble showcasing blog posts with an image. Currently, I am utilizing card-columns from Bootstrap 4, and when the user hovers over the image, it scales up. The issue arises when the transition occurs, as my border radius resets to defaul ...

Error message in Vuejs: The injection "Symbol()" could not be found

I encountered an issue while using confirmdialog in primevue. The error message I received is: [Vue warn]: injection "Symbol()" not found I am unsure of the cause of this error and how to resolve it. Any assistance would be greatly appreciated ...

Building a matrix of checkboxes

I am looking to design a grid of checkboxes that are displayed in columns, with 5 checkboxes in each column. <ul class="checkbox-grid"> <li><input type="checkbox" name="text1" value="value1" /><label for="text1">Text 1</lab ...

What could be causing the modal to not appear when clicking on this div?

$(function() { $("#pagination a").trigger('click'); // When the page loads, trigger a click event $('body').on('click','div.well well-sm',function(){ var list = $(this); $('#myModal .modal-title').h ...

The specified element "errors" is not found in the VeeValidate template

Trying to use VeeValidate for field validation in a Vue form with Vue 2.5 and VeeValidate 2.1, the following method is used: <input class="form-control" name="contact-email" id="contact-email" type="email" v-model="contact-email" v-validate="'re ...

What is the best way to achieve consistent appearance across all browsers and various screen sizes?

I have implemented owl carousel on my website for sliding the container. While the slider functions correctly, I encounter issues when minimizing the screen or viewing it on different monitors or browsers. The problem lies in the fact that the code is not ...