Customizing the background color in Bootstrap 4 without impacting the container

Hey there, I'm currently working on a login page for my website. However, I've run into an issue where changing the background also changes the color of my div container. How can I resolve this problem so that only the background changes?

Below is the Bootstrap 4.6 code I have written:

<section class="vh-100 gradient">
    <div class="container">
        <div class="row">
            <div class="col-sm-9 col-md-7 col-lg-5 mx-auto">
                <div class="card-border-0 shadow rounded-2 my-5 mx-3">
                    <div class="card-header p-1 p-sm-3">
                        <h3>Client Management Portal</h3>
                    </div>
                    <div class="card-body p-4 p-sm-5">
                        {%include "components/alerts.html"%}
                        <form action="" method="post">
                            {%csrf_token%}
                            <div class="form-floating mb-3">
                                <label for="password">Username</label>
                                {{form.username}}
                            </div>
                            <div class="form-floating mb-3">
                                <label for="password">Password</label>
                                <div class="input-group form-floating mb-3">
                                    {{form.password}}
                                    <div class="input-group-append bg-white" id="">
                                        <span class="input-group-text" id="passwd">
                                            <i class="fas fa-eye-slash"></i>
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <div class="d-grid">
                                <button class="btn btn-success">Login</button>
                            </div>
                        </form>
                    </div>
                    <div class="card-footer p-2">
                        <a class="text-muted" href="#">No account? register here</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<style>
    .gradient-custom {
    /* fallback for old browsers */
    background: #6a11cb;
  
    /* Chrome 10-25, Safari 5.1-6 */
    background: -webkit-linear-gradient(to right, #36D1DC, #5B86E5);
  
    /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    background: linear-gradient(to right, #36D1DC, #5B86E5)
  }
</style>

https://i.sstatic.net/48eu5.png

Appreciate your help in advance! (edit : please dont mind the double curly braces, django template only thanks again)

Answer №1

To change the background color of the container class, simply update your CSS as shown below:

<style>
      .gradient {
        /* fallback for old browsers */
        background: #6a11cb;

        /* Chrome 10-25, Safari 5.1-6 */
        background: -webkit-linear-gradient(to right, #36d1dc, #5b86e5);

        /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
        background: linear-gradient(to right, #36d1dc, #5b86e5);
      }

      .container {
        background: #fff; 
      }
 </style>

Answer №2

One can compose in this manner:

<div class="wrapper" style="background-color:white !important;">

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

Two nested divs positioned below text within a parent div

I am styling a content div with text and two child divs positioned next to each other within the content div. My goal is to have the child divs display below the text, rather than beside it. body { text-align: center; } #first, #second { border: so ...

Adaptive website backdrop

I have created a unique background for my website design, which includes 3 slices labeled as div id top, middle, and bottom. You can view the design in this image. I am interested in making this background responsive. While I have come across examples of ...

Concealing Bootstrap Dialog in Angular 6 through Component隐藏Angular 6中

I have been struggling to hide a bootstrap dialog from a component with no success. Here is my Dialog code: <div class="modal fade" id="loading_video_upload" tabindex="-1" role="dialog" aria-labelledby="loading_video_upload_label" aria-hidde ...

Is the background color extending the entire width of the page?

Hey there, I'm currently trying to determine how to set the background-color on a paragraph or h1 so that it only appears behind the words and not across the entire page with blank space. I'm still a beginner when it comes to coding. I'm wor ...

Paged Content: Turning a Lengthy Text into a Book-Like Format

I have a unique idea for displaying text like a flipping book on a web page. Users can use arrow keys to navigate through the content, giving it an interactive and engaging feel. Instead of focusing solely on page transitions, I am looking into implementi ...

The alignment of elements on the right and left sides is not functioning as intended

I've been facing an issue with the alignment of my floats on my brand new website www.unicmedia.nl/case/oranje. Surprisingly, they seem to work fine in IE this time, but Firefox and Chrome are completely out of sync. Despite trying numerous solutions ...

Storing user input in an existing text file using ASP.NET MVC

What steps should I take to store user form input from a view into an already existing text file using the ASP.NET MVC framework? ...

"Enhance Your Dining Experience with a Menu that Captiv

My goal is to create a small menu with only the initial letter of each name visible, but when focused, I want the full word to appear. Here's an example: css: .menu:focus { } php: <nav> <li class="menu"><a ...

Minimum number of cards in each column

I'm currently utilizing media queries to make sure that my card-columns are shown in a responsive manner. However, I have noticed that there is a minimum requirement of 2 cards in each column before it moves on to the next one (from left to right). T ...

Organized grid design where every element occupies its own required space

Here's the current image I have displayed: https://i.sstatic.net/qKH8x.jpg This image is being styled by the following code: .gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); } I've been searching for a solution ...

The process of rendering a form eliminates the classes that were previously added by J

I am in the process of redesigning a web application and need to incorporate responsive design into the existing UI. My plan is to include col-* classes on specific html elements, such as tables: function addColstoTableCells() { $('table tr.form ...

Swap File Field for Picture Graphic - HTML/CSS

I am looking to enhance the appearance of my form by replacing the generic File Field with a more aesthetically pleasing Image Icon. If you click on this Camera Icon, it will open up a Browse window: For a demonstration, check out this JsFiddle link: htt ...

Content within the two inline divs is experiencing alignment problems?

I am experiencing alignment issues with the content inside two divs that contain multiple nested divs. The content is not properly aligned. CSS Code: .breadcrumb-nav{ margin-left: 230px; left: 70px; top: 70px; width: 1291px; height: 6 ...

Arranging links in a horizontal line (JSFiddle)

CodePen: https://codepen.io/example/abc123 I am attempting to align the elements "Favourite", "0", and "Reply" next to each other so they appear as: Favourite 0 Reply ...

Writing and altering content within the <code> element in Chrome is unreliable

Utilizing a WYSIWYG Editor with contenteditable functionality allows users to input "code snippets" using a <code> element. Here is an example: <div contenteditable="true"> <p> This is a paragraph with an <code>inline s ...

Accessing the clandestine div via direct hyperlink

I have incorporated a toggle plugin from this website to display hidden divs. Each hidden div is identified by a unique id. Is there a method to show a specific div using a direct link? For instance, by entering domain.com/page.php#HiddenDiv2, it should ...

Is there a way to access other HTML pages in a separate folder from the index file when running npm start?

At the moment, I have a simple index.html file and would like to access the app.html file located in a subfolder from the index.html. You can see the folder structure here: https://i.sstatic.net/IGcOk.png My app.html file is inside the 'app' sub ...

What is the best way to center a div vertically inside another div?

Aligning a div element horizontally within another div element is possible by using the margin: 0 auto; property as long as both elements have a specified width other than auto. However, this method does not work for vertical alignment. Is there a way to ...

Print directly without the need for a preview or dialog box

Is there a way to easily print content with just one click, without having to go through the preview or print dialog box? Here is a snippet of my code: <head> <style type="text/css"> #printable { display: none; } @media print { #non-pr ...

Expand the image background to fit within a div container

Below is the code snippet I am working on: <div id="intro_section_upper" > <%= image_tag("video_background.jpg", :id=>"video_bg") %> <div id="video_table_main" > <table class=" ...