How can the Bootstrap Jumbotron element be adjusted to perfectly fill the width of the screen?

Currently, I'm utilizing a jumbotron element on my website and aiming to make it fluid in order to adapt and fit the entire jumbotron to the screen width. However, I seem to be facing difficulty when attempting to increase its width.

Below is the code snippet I'm working with:

    $(".jumbotron").css({ height: $(window).height() + "px" });
    
    $(window).on("resize", function() {
      $(".jumbotron").css({ height: $(window).height() + "px" });
    });
    $(".form-control").click(function(){
      $(this).prev().val("");
    document.getElementById("inzone").style.display = 'block';
    document.getElementById("outzone").style.display = 'block';
    
    });
    .jumbotron {
      color: white;
      background-image: url("picture link");
      background-position: 100% 100%;
      background-repeat: no-repeat;
      background-size: cover;
      height: 100vh;
      
     }
     
    
    .wrap{
      width: 60%;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">

    
    <div class="jumbotron jumbotron-fluid">
      <div class="container">
        
    <div class="wrap">
       <div style="text-align: center;"><label style="font-weight:bold;">Select your location to find best offers available:</label></div>
    <div class="form-froup">
    <div class="input-icons">
    <i class="fa fa-search icon"></i>
      <input type="search" class="form-control" id="search_input" placeholder="Enter Area Name" />
      </div>
    </div>
    </div>
           
      </div>
    </div>

Answer №1

In my opinion, this piece of code could be beneficial for your needs. I have incorporated a large grey box designed as a Jumbotron for visual appeal.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <style>
        .jumbotron{
            position: relative;
            top: 200px;
            height: 300px;
        }
        .wrap{
            width: 60%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
</head>
<body>

<div class="jumbotron jumbotron-fluid">
    <div class="container">
        <div class="wrap">
            <div style="text-align: center;"><label style="font-weight:bold;">Choose your location to discover the best available offers:</label></div>
            <div class="form-froup">
                <div class="input-icons">
                    <i class="fa fa-search icon"></i>
                    <input type="search" class="form-control" id="search_input" placeholder="Enter Area Name" />
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(".jumbotron").css({ height: $(window).height() + "px" });

    $(window).on("resize", function() {
        $(".jumbotron").css({ height: $(window).height() + "px" });
    });
    $(".form-control").click(function(){
        $(this).prev().val("");
        document.getElementById("inzone").style.display = 'block';
        document.getElementById("outzone").style.display = 'block';

    });
</script>

</body>
</html>

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

Display additional information upon hovering without disrupting the neighboring elements

When I hover over a component, I want to display more details and scale it up. However, this action ends up displacing the surrounding components. Take a look at the screenshot for reference: https://i.sstatic.net/ElXvk.jpg Below is the code snippet wher ...

Having trouble with Github pages' responsiveness on certain devices

The responsive view in the browser appears to be working correctly. Everything is functioning fine. However, when I switch to my Android phone, the alignment is off. I've tested it on multiple devices and the results are consistent. What could be cau ...

Guide on serving static HTML files using vanilla JavaScript and incorporating submodules

Is it possible to serve a static html file with elements defined in a javascript file using imports from submodules using vanilla JS? Or do I need bundling tools and/or other frameworks for this task? Here's an example code structure to showcase what ...

Update links within a designated div section

How can I change the color and alignment of anchor tags within the third child div that is part of a set of three nested divs? These child divs are arranged side by side within a parent div with the class .logo-bckgrnd-rpt. Although I have successfully tar ...

Looking for guidance on integrating Forms with VueX and script setup? Are you utilizing v-model in your implementation?

UPDATE: I'm contemplating whether or not to abandon VueX entirely due to its outdated status, with Pinia being the preferred choice nowadays. Can someone confirm this? https://stackblitz.com/edit/vue-script-setup-with-vuex-hmrk5d?file=src/store.ts ...

Unable to showcase array JSON values on HTML using ng-model

Utilizing ngTagInput for autocomplete textbox and successfully receiving suggestions. To display the values of data-ng-model (named "list") I am using: {{list}} and it is showing correctly. However, when selecting "list1", the display appears as: [{"lis ...

What is the best way to generate script code dynamically on an HTML page depending on the environment?

I am facing a challenge with my asp.net application. I need to insert a dynamic script into the html section, and this script's value must change depending on the environment (TEST, QA, etc.). To illustrate, here is the script where DisplayValue is th ...

HTML 5 File selection on iOS and Android using Cordova/Phonegap

I attempted to utilize the camera in a PhoneGap app using the HTML5 input tag as shown below. Create a new project through CLI Add iOS and Android platforms Incorporate the camera plugin Build for both devices Run on iPhone 5 with iOS 7.1.2 and Samsung N ...

Instructions on how to make the image within this div expand to full screen in order to cover up the blue background color

I created a div and set its background image, but the image is not covering the full screen. There's some space around it. The blue color is the body color. Please refer to the image here I am very new to web development, so please forgive my silly ...

Creating a simulated dropdown menu using only CSS

I was able to create a select menu using only CSS, following some code I found. However, I am now facing an issue with overlaying divs. Whenever I hover or click on the "select menu", all the divs below it move down. I've attempted to adjust the z-i ...

Bootstrap Navbar Not Extending Across Entire Width or Reaching Top Edge

I'm running into an issue with the Bootstrap navbar within my React project. The navbar is not extending across the entire width of the screen, resulting in empty space on both the left and right sides. Additionally, there is a gap between the navbar ...

Steps for revealing all the information from a database when clicking on the 'Read More' button

I recently set up a database called Magazine, featuring a table named social_media. This table consists of 5 columns: ID, Headline, Author, Content Short, Content. The Content Short column contains condensed versions of the articles which are displayed on ...

What steps can be taken to turn this html code and css into a mobile application?

I have begun working on my HTML and CSS but need some guidance to create a mobile app without needing to resize it when accessed through the web. Additionally, I would like to make it responsive in CSS. Can you provide me with the necessary code? @c ...

Creating a multi-level signup page in Angular 4 using Bootstrap

Currently, I am working with angular 4 and bootstrap 4 to create a multi-level sign-up page. One of the challenges I am encountering is how to properly include a JavaScript file into my angular project. import '../../../assets/js/js/multiform.js&apo ...

Ways to ensure a <div> element adjusts its height based on inner content dimensions

When using buttons in a chatbot that have text which changes based on selected options, I've encountered an issue where the text length sometimes exceeds the button's space. I'm looking for a way to make the containing div automatically adj ...

The propagation of SVG events from embedded images via the <image> elements

I'm currently developing a diagramming tool using HTML, CSS, and Javascript with SVG for the drawing canvas. This tool consists of predefined "building blocks" that users can place on the canvas, rather than allowing free-hand drawing of shapes. Each ...

What significance do the blank quotes hold in terms of value?

Is it possible to enter multiple values for the "favoriteCities" field since the value is empty? <input name="favoriteCities[]" value=""/> ...

Submit a list of checkboxes selected to Google Sheets separated by commas

Is there a way to modify the script I'm using to enter data from an HTML form into a Google Sheet so that my checkbox fields will be entered as a list, separated by commas? If all boxes were checked in the example form below, I would like the cell fo ...

Is there a way to simulate pressing a keyboard button using jQuery?

Below is the code snippet: $("input").on({ keydown: function(ev) { if (ev.which === 27){ // esc button backspace_emolator(); } else if (ev.which === 8){ // backspace button console.log('backspace button ...

In order to format my text, I must locate a specific character and encompass the text following it with HTML tags

When working with a list generated in Jekyll, I came across the need to emphasize certain words using strong tags. My solution was to incorporate a delimiter into the process. <li>100g of |sugar</li> This would transform into: <li>100g ...