The page jerks as the carousel adjusts its height and content

There's an intriguing issue I'm encountering on my webpage with the bootstrap carousel wrapped inside a wrapper set as position:absolute. When the page is slightly scrolled down and the next carousel-item has a different height, the page abruptly "jumps".

The home-hero-wrapper is set at 100vh, and the carousel-home-wrapper, which wraps the carousel, is positioned absolutely at the bottom. Regardless of the size of the carousel-item, it should align at the bottom of the home-hero-wrapper.

The Issue: Everything works smoothly until the page is scrolled down a bit (with the carousel still in the viewport) and during the carousel transition, the page unpredictably "jumps". Despite home-hero-wrapper maintaining its size, I can't determine why the sections are acting this way.

What could be missing here? Any suggestions?

Below is the code snippet replicating the problem:

.home-hero-wrapper {
  height: 100vh;
  min-height: 200px;
  position: relative;
}
.carousel-home-wrapper {
  position: absolute;
  bottom: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="home-hero-wrapper bg-info">
    <div class="hero-image" style="background-image: url(https://via.placeholder.com/1024x800);">
    </div>
    <div class="carousel-home-wrapper">
            <div 
              id="carousel_home" 
              class="carousel slide carousel-fade" 
              data-ride="carousel"
              data-interval="1000"
             >
                <div class="carousel-inner">
                    <div class="carousel-item bg-light active">
                        <h2>Content Shorter</h2>
                        <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</p>
                    </div>
                    <div class="carousel-item p-3 bg-light">
                        <h2>Content Longer</h2>
                        <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dolorem rem earum temporibus perferendis corrupti minus harum, ex ipsam molestiae iste dicta voluptatum mollitia quia animi ut, soluta molestias natus ipsa.</p>
                    </div>
                </div>
            </div><!-- #carousel_home -->
        </div><!-- .carousel-home-wrapper -->
</div><!-- home-hero-wrapper -->
<div class="p-5 bg-warning">
  <h2>Scroll until here</h2>
  <h3>Make sure carousel still visible</h3>
  <p>Waiting until carousel transition... All sections will "jump"</p>
</div>
<div class="p-5">
  <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dolorem rem earum temporibus perferendis corrupti minus harum, ex ipsam molestiae iste dicta voluptatum mollitia quia animi ut, soluta molestias natus ipsa.
</div>
<div class="p-5">
  <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dolorem rem earum temporibus perferendis corrupti minus harum, ex ipsam molestiae iste dicta voluptatum mollitia quia animi ut, soluta molestias natus ipsa.
</div>
<div class="p-5 bg-danger">
  <h2>Make sure carousel still visible</h2>
</div>

Answer №1

To begin, include the p-3 class in both instances of carousel-item <div>, or remove it from both.

Next, delete all classes from the <div> with the ID #carousel_home.


Additionally, apply the following CSS:

.carousel-item{
  height: 130px;
}

If the text within the carousel-item is shorter than the full width of the page, it will only occupy that amount of width.

If the text inside the carousel-item exceeds the width of the page, it will automatically wrap to the next line.

Furthermore, it will be aligned with the home-hero-wrapper class at the bottom of the page. Check out the live code example using the link provided below (NEW)


View the live code here (NEW): https://codepen.io/manaskhandelwal1/pen/QWbpvMW


View the live code here (OLD): https://codepen.io/manaskhandelwal1/pen/zYGNyxg


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

Styling the CSS tables with alternating row styles for rows 1 and 2, followed by a different style for rows 3 and 4. This pattern will repeat

I've been struggling to create a CSS table style using tr:nth-child to alternate row colors: Row 1 - Blue Row 2 - Blue Row 3 - White Row 4 - White ... and so on. I can't seem to get it right! Can anyone help me out with this? Appreciate an ...

What is the best way to incorporate next and previous buttons into my slideshow using jQuery?

Looking to enhance my slideshow by incorporating the ability to pause, go to the next or previous image, along with the automatic transitioning feature currently in place. I'm a bit unsure on how to implement these event handlers efficiently within my ...

Get rid of the blue outline border when embedding Google Maps

Does anyone know how to remove the blue focus border that appears when clicking on an embedded Google Map? I've tried various CSS styles without success: *:focus { outline: none !important; border: none !important; } iframe { outline: no ...

Converting arrays in a JSON file into HTML formatting

After going through several questions on Stack Overflow, I haven't found a solution for my specific issue. Other questions seem to focus on formatting data from complete JSON files, while my question is about formatting elements of an array parsed fro ...

Styling the text of segmented bars in ControlsFX using CSS

Is there a way to customize the size and color of the text for the ControlsFX segmented bar? I've attempted the typical method: -fx-font-size: 15px Unfortunately, it doesn't seem to be effective. Whether it's through CSS or code, I'm ...

Steps for adding a table at the bottom of your content

After hours of searching, I am still struggling to find a solution for my problem. My goal is to have the menu2.html appear at the bottom of the page, after the end of the content. I've tried various options like setting positions and using CSS styles ...

Looking for a smart way to extract all the selected elements from a form?

I am attempting to retrieve all the checked items from this form using JavaScript. I have looked at previous solutions, but none of them fit my requirements. <form id="checkform" class="container" style="margin-top:20px;"> <input type="checkb ...

To activate two separate click events, one for an absolute element and another for the element positioned behind it, simply click on the desired absolute element to trigger both actions

Is it possible to trigger click events for both of these elements? position: relative container ELEMENT 1: standard div ELEMENT 2: position: absolute div In real life, element 2 is a transparent backdrop designed to capture clicks on top of the header ...

css3 google site opacity

I am attempting to create a transparent container for my website on Google Sites in order to display the background image. Unfortunately, it seems that the opacity property of CSS3 is not supported on Google Sites. Are there any alternative methods to ac ...

The delete button in the Bootstrap modal is functional, however, there seem to be issues with its successful

Having an Issue with Bootstrap Modal in My View. <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 c ...

Achieving left alignment for Material-UI Radio buttons: Float them left

Click here to view the demo https://i.stack.imgur.com/Yt4ya.png Check out the demo above to see the code in action. I'm currently struggling to align the radio buttons horizontally, wondering if there's an easier way to achieve this using Mater ...

Picture will not be included in the SQL database

When users fill out a HTML form to register for a competition, everything successfully enters into the database except for the Photo Name and Photo. Any ideas on why this might be happening? HTML Form: <form method="post" action="addboat.php"> &l ...

Placing information into a table cell using d3 library

Looking to insert text into a cell using d3? I have a function with the necessary code, which I am calling in the body of an HTML page. Here is a sample of the code that I am trying to get working: <!DOCTYPE html> <html> <head> <link ...

Alert: The comment index is not defined on line 5 of the comment.php file located in C:xampphtdocsindex

There is a piece of code I am struggling with: <?php if($_POST){ $name = $_POST['name']; $content = $_POST['comment']; $handle = fopen("comments.html","a"); fwrite($handle,"<b>" . $name . "</b><br ...

Transform URL Structure with UrlRewrite and htaccess - A Step-by-Step Guide

Currently, I am using the following URL: http://server.com/index.php?page1=main&page2=contacts I would like to change it to: http://server.com/main/contacts Can anyone provide guidance on how to write an .htaccess file with sample code for this red ...

Bootstrap4 navigation bar featuring a collapsible centered logo and two rows for enhanced functionality

Can you help me customize my Navbar for a 2-row layout? CompanyLogo link link link ----------------------------------------------------------------------- link(dropdown) link link link lin ...

JavaScript encounters an Access Denied error when attempting to read data from a JSON file in

My code is experiencing issues on IE browser and Chrome, but works perfectly on FireFox. var currentPage = 1; var max = 0; var myList = []; var links = []; $.ajax({ cache: false, type : 'GET', crossDomain: true, ...

Using Express and Node.js to implement the Google Maps API

Currently working on creating a simple web application using the Google Maps API with express/node. At the moment, I have three main files that make up my project: server.js const express = require('express'); const bodyParser = require(' ...

Attempting to implement image switching with hover effects and clickable regions

Hey there, I'm currently working on a fun little project and could use some guidance on how to achieve a specific effect. The website in question is [redacted], and you can view the code I've used so far at [redacted]. You'll find a code blo ...

Tips for synchronizing JavaScript rendering time with Python requests?

My goal is to retrieve the HTML content of a JavaScript-generated website so that I can extract information using BeautifulSoup. However, when I attempt to request the HTML, the data I receive is from before the page fully loads. Below is the code snippet ...