Utilizing the Bootstrap 4 jumbotron classes to create an interactive image carousel

I've made good progress on my mockup website by laying out the basics.

#hero {
    background: url("https://picsum.photos/1280/710") no-repeat center;
    background-size: cover;
}

.book {
    height: 100px;
    width: 100px;
    bottom: 9vh;
}
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="./styles.css">
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
    <title>Etomon</title>
</head>
<body>
    <div class="jumbotron jumbotron-fluid hero" id="hero">
        <div class="container">
            <div class="row">
                <div class="col-12 col-md-7 mb-4 book">
                    <img src="./images/book.png" class="book">
                    <h1 class="logo h2 text-light">Etomon</h1>
                </div>
                <div class="col search">
                    <input type="text" class="" placeholder="Search?">
                    <button type="submit">Submit</button>
                    <form>
                        subject/course <br>
                        <input type="text" placeholder="Graphic Design"> <br> level <br>
                        <input type="text" placeholder="Intermediate"> <br> starting <br>
                        <input type="text" placeholder="mm/dd/yyyy"> <br> ending <br>
                        <input type="text" placeholder="mm/dd/yyy"> <br>
                        <button type="submit">Submit</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div class="container">
        <div class="row">
            <div class="col">
                <h1 class="popular text-center">Most Popular Subjects</h1>
            </div>
        </div>
    </div>
</body>
</html>

To enhance the design, I aim to include an image carousel in the .jumbotron div for a similar aesthetic as shown in this screenshot. https://i.sstatic.net/YwbUY.jpg

In the CSS provided, #hero is set to display the background image. When attempting to replicate the w3s Bootstrap carousel, the carousel appears above the content. How can I ensure it stays within the jumbotron section?

Answer №1

If you want to achieve a similar effect, consider the following approach:
The element with the ID #carousel is positioned absolutely and stretched to occupy the entire space of the jumbotron. To make this layout work, the jumbotron has been given an explicit style of position: relative. Additionally, both the .carousel-inner and .carousel-item classes have their height set to 100% to fill the available space. Since .carousel-item now only functions as a background container, its height must be explicitly defined.

#hero {
    position: relative;
}
#carousel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

.carousel-inner,
.carousel-item {
    height: 100%;
}
.carousel-item {
    background: no-repeat center/cover;
}

.book {
    height: 100px;
    width: 100px;
    bottom: 9vh;
}
<div class="jumbotron jumbotron-fluid hero" id="hero">
    <div class="container">
        <!-- The carousel goes here, using `position:absolute` -->
        <div id="carousel" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
                <div class="carousel-item active" style="background-image:url('https://picsum.photos/1280/710')"></div>

                <div class="carousel-item" style="background-image:url('http://via.placeholder.com/1280x710/adeee3/ffffff?text=Another+image')"></div>
            </div>
        </div>

        <div class="row">
            <div class="col-12 col-md-7 mb-4 book">
                <img src="./images/book.png" class="book">
                <h1 class="logo h2 text-light">Etomon</h1>
            </div>
            <div class="col search">
                <input type="text" class="" placeholder="Search?">
                <button type="submit">Submit</button>
                <form>
                    subject/course <br>
                    <input type="text" placeholder="Graphic Design"> <br> level <br>
                    <input type="text" placeholder="Intermediate"> <br> starting <br>
                    <input type="text" placeholder="mm/dd/yyyy"> <br> ending <br>
                    <input type="text" placeholder="mm/dd/yyy"> <br>
                    <button type="submit">Submit</button>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="container">
    <div class="row">
        <div class="col">
            <h1 class="popular text-center">Most Popular Subjects</h1>
        </div>
    </div>
</div>


<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

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

Preventing div resizing in AngularJS through scroll functionality

I want to create dialog boxes that are draggable and resizable and can contain arbitrary HTML-formatted content. To achieve this, I am utilizing JQLite within a directive. The resizing functionality is triggered by a mousedown event on a div in the bottom ...

Steps for signing up for an ngRx state

Currently, I am setting up an ngrx app to further my understanding and skills, even though the project is quite small. The project involves managing a beer inventory. Within one of the components, I aim to display a list of beers: export class BeerListC ...

Error: Attempting to use Moment with Bootstrap Date Time Picker results in TypeError, as Object(...) is not recognized as

Let me show you the code for my picker in a simple way: import {moment} from 'moment'; const datePicker = () => { $('.datetimepicker').datetimepicker({ format: 'LT', locale: 'PT-BR', icons: { ...

JQUERY function fails to execute following the invocation of an array

There is an array named NAME being created. Weirdly, the code seems to be functioning fine for alert('test1') but encounters an issue when reaching alert('test2') $(document).on('submit','form',function() { ...

What are the best practices for creating a contemporary website that functions effectively on IE7?

After creating several websites for my clients, I discovered that they are not functioning well in IE7. Unfortunately, there is still a small percentage of people using IE7. Can anyone suggest a super quick solution to fix this issue? Feel free to recomm ...

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

Centered Navigation Links with Logo Positioned on the Left in Bootstrap 5

I've been struggling to create a centered navbar in Bootstrap 5 with left-aligned brand logo. Despite trying various flexbox options, I can only manage to center the nav links within a flex container. However, the collapse feature functions correctly. ...

Bower downloads the identical package but arranges it in a distinct file structure

We operate a TeamCity build server that is utilizing three different buildusers all configured similarly. We have integrated an angular/grunt project using yeoman Update 6 Noted an issue with bower https://github.com/bower/bower/issues/1709 Why does bow ...

Is it possible to return to the previous page in Vue by using window.history.go(-1)?

Greetings! I am currently developing a website using Vue, but I have encountered an issue. Initially, I tried using router.go(-1) to prevent access through the address bar (e.g., from ../client/mypage to ../admin/mypage) and to redirect to the previous pag ...

Error: 'err' has not been defined

Recently, I embarked on creating my very first API using Mongo, Express and Node. As I attempted to establish an API endpoint for a specific user, the console threw me this error: ReferenceError: err is not defined. Curiously, the same method worked flawle ...

Guide to creating a sortable element that can act as a droppable area when dragging other sortable items over it

My grid consists of both icons and groups (folders). I want to make both the icons and the groups sortable, with the condition that the groups remain stationary and act as drop targets for the icons. Moving a group within the larger sortable should be feas ...

Displaying inner words in an array vertically using Vue JS

I'm facing an issue with the positioning of time elements in my array on the browser. They are currently located at the bottom, but I need them to be displayed on the sides. I attempted to solve this problem using CSS, but without success. Then, I tri ...

Trouble getting AngularJS $scope arrays to populate with multiple PHP to MySQL queries

In my Angular controller, I used to fetch data from a PHP file that pulled one query from the database, stored it in a scope array, and displayed it on the webpage successfully. However, now I am trying to execute two queries in the same file. Each query ...

Enhance the appearance of your angular chosen container with personalized classes

LINK : Click here to view the code HTML <!DOCTYPE html> <html ng-app="plunker"> <head> <meta charset="utf-8" /> <title>AngularJS Plunker</title> <link data-require="chosen@*" data-semver="1.0.0" rel=" ...

apply white-space:nowrap to a single column in a datatable

I am facing a challenge with my bootstrap datatable where one row (Product) contains a large amount of data and currently expands downwards, taking up a lot of space. https://i.sstatic.net/BryzM.png My goal is to make the Product column expand to the rig ...

Extensive application featuring a complex form built with react-redux

Recently, I've been tasked with revamping a module at my company using react. This module consists of a single page that is made up of 4-5 different forms. The selections made in each form determine the appearance of the following form step. While th ...

Tips for adding new items to a Masonry Image List using React MUI

As I experiment with utilizing the React MUI Masonry Image List alongside the infinite scroll, I've found that they complement each other quite well. However, a challenge arises when appending new images to the Masonry image list. While I can success ...

Executing asynchronous methods in a Playwright implementation: A guide on constructor assignment

My current implementation uses a Page Object Model to handle browser specification. However, I encountered an issue where assigning a new context from the browser and then assigning it to the page does not work as expected due to the asynchronous nature of ...

Connecting the search results page with the specific details page

Currently, I am developing a results page for my website and require assistance with linking each restaurant to a detail.php page. The project involves showcasing all the restaurants in San Francisco along with their health inspection scores, address, and ...

Page for users to login using React

Struggling to create a login page in React due to the asynchronous nature of setState. Upon submission, the state is not updating with form values, only displaying old initial values. How can I ensure that the submit function receives the new values? Is ...