What is the best way to extract a color box from a Bootstrap container?

After trying multiple solutions found online, I'm still struggling to break out of the bootstrap container as needed. The setup involves a .fluid-container for a full-width background behind a regular .container. The challenge arises when the first column in .container needs to extend all the way to the left edge of the screen.

Expected Result:

Current Outcome:

Here is the HTML code:

<div class="container-fluid bg-darkblue bg-image-footer py-5">
        <div class="container">
            <div class="row" id="footer-content">
                <div class="col-5 px-0 py-3 bg-limegreen">
                    Form content goes here.
                </div>
                <div class="col-1">&nbsp;</div>
                <div class="col-2 text-white">
                    <p class="avenir text-limegreen text-upper">Contact Us</p>
                    <p>(202) 555-1212</p>
                    <p><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="16737b777f7a56737b777f7a3875797b">[email protected]</a></p>
                    <p>New York, NY</p>
                </div>
                <div class="col-2">
                    <p class="avenir text-limegreen text-upper">Client Name</p>
                    <p>About</p>
                    <p>Careers</p>
                    <p>Accessibility</p>
                </div>
                <div class="col-2">
                    <p class="avenir text-limegreen text-upper">Social</p>
                </div>
            </div>
        </div>
    </div>

To clarify, the objective is to align the left edge of the lime green box with the left edge of the screen, without disrupting the grid system or layout.

The CSS mostly follows Bootstrap 5 standards, with a few modifications like .bg-limegreen for color control.

Answer №1

Make sure to avoid directly nesting containers within Bootstrap layouts. It's best to stick to the standard row/column nesting to maintain clean and organized code. Only break out of this structure if you absolutely need to overlap content across columns, which is rarely necessary.

Furthermore, consider utilizing existing Bootstrap classes like text-light and text-uppercase instead of creating custom classes. Familiarize yourself with Bootstrap's features to prevent unnecessary CSS bloat in your project. Explore Bootstrap's text utilities for more options.

Additionally, when assigning colors, override Bootstrap's semantic color classes rather than introducing new non-semantic ones. For instance, consider using text-success instead of creating a new class like text-limegreen. Take a look at Bootstrap's color utilities for guidance.

.bg-darkblue {
  background: darkblue;
}

.bg-limegreen {
  background: limegreen;
}

.text-limegreen {
  color: limegreen;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="14767b7b60676066756454213a253a27">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="container-fluid bg-darkblue bg-image-footer py-5">
  <div class="row" id="footer-content">
    <div class="col-5 px-0 py-3 bg-limegreen">
      <div class="row justify-content-end">
        <div class="col-8 text-light">
          Form content goes here.
        </div>
      </div>
    </div>

    <div class="col-1"></div>

    <div class="col-6">
      <div class="row justify-content-start text-light pt-2">
        <div class="col-3">
          <p class="avenir text-limegreen text-uppercase">Contact Us</p>
          <p>(202) 555-1212</p>
          <p><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9efbf3fff7f2defbf3fff7f2b0fdf1f3">[email protected]</a></p>
          <p>New York, NY</p>
        </div>

        <div class="col-3">
          <p class="avenir text-limegreen text-uppercase">Client Name</p>
          <p>About</p>
          <p>Careers</p>
          <p>Accessibility</p>
        </div>

        <div class="col-3">
          <p class="avenir text-limegreen text-uppercase">Social</p>
        </div>
      </div>
    </div>
  </div>

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

Blazor Razor Component Library (RCL) Lacks CSS IntelliSense

I am encountering an issue with the CSS intellisense in my razor class library (RCL) that houses all the pages of my Blazor application. It appears that the CSS intellisense is not functioning within the RCL unless I modify the RCL .csproj xml tag From Sdk ...

Looking to update the background color of a div every 3 seconds?

Every 3 seconds, I need to change the background color of each div. To do this, I attempted to modify the values in the color array every 3 seconds. For example, the value at index 0 (which is "red") would move to index 1, then the value at index 1 would ...

Adjust the input value with CSS when hovering

Whenever I click on a button, the name of that button is displayed on the site. However, I am looking to change this button name when hovering over it but I am not sure how to do it. echo '<form id="button" method="POST" >&ap ...

Difficulty with JQuery Show and Hide Functionality

I've implemented a jQuery menu, but encountering the issue where clicking on any menu link opens all menus instead of just the one clicked. I've attempted to resolve this by using show and hide classes, however, it seems that nothing is working n ...

What is preventing relative paths from functioning with xsl:include?

I am working with an XSL file that converts to PDF. The top of the page contains a lengthy CSS style declaration: <xsl:attribute-set name="Header"> <xsl:attribute name="font-size"> <xsl:value-of select="$font-size"/> < ...

What is the best way to display multiple HTML files using node.js?

click here to see the image Here is my server.js file. Using express, I have successfully rendered the list.html and css files on my server. However, I am encountering an issue when trying to navigate from list.html to other html files by entering localho ...

Tips for fading the text of list items when their checkbox is marked as done?

I am trying to figure out how to gray out a list item when its checkbox is checked. The code I currently have takes text input from a textbox and adds it to an unordered list when the add button is clicked. Each list item contains a checkbox within it. My ...

Interactive jQuery Dropdown Menu with Multiple Divs

I have been working on this and I'm almost there, but the jQuery part is driving me crazy (I'm not very proficient in it yet, but I am learning). Here's the link to the fiddle: http://jsfiddle.net/5CRA5/4/ Since I can't demonstrate th ...

What is the best way to update the content of a modal using jQuery and AJAX?

Despite previous inquiries on this matter, none of the answers provided have been helpful to me. Therefore, I am addressing the issue again... I am currently developing the frontend of a website that does not involve any backend functionality (no server c ...

Utilizing spans to adjust the formatting of text within list items

When it comes to shaping text inside li elements, I've encountered a few issues. One of the problems is that the float-right divs aren't floating to the top right corner but instead leaving a space at the top. Additionally, the text isn't &a ...

When utilizing an API to render text into a div, the offsetHeight function may return 0

I'm working with a div that displays text fetched from an API call. I'm trying to implement a See more button if the text exceeds 3 lines. Here is my approach: seeMore(){ this.setState({ seeMore: !this.state.seeMo ...

What are some ways to eliminate the excess white space beneath the footer in HTML?

After creating a responsive webpage that works flawlessly on mobile devices and tablets, I noticed a problem with the footer when viewed on desktop. There is an empty white space at the end of the webpage, and upon inspecting the browser, it focuses on the ...

Card Alignment with Bootstrap

I need help aligning the last two elements in the card. I want the first one (a button) to be on the left, and another element (a Div with multiple social icon images) on the right side. Can someone provide guidance on how to achieve this layout? <!D ...

Enhancing the Appearance of Google Line Charts

Incorporating Google line charts into my upcoming web project has been a goal of mine. I aim to customize them in the style displayed in this image and display dates between months. Can anyone provide guidance on how to achieve this, if it is feasible? ...

Is there a sweet syntax for CSS variables available?

What about using this instead: :root { --primary-color: gray; --secondary-color: lightgray; } var(--pc) Is there a more concise syntax available, perhaps shorter than var(--pc)? ...

Modifying HTML Email to Achieve Consistent Rendering Across Various Email Platforms

While creating an HTML based email for our subscribers, I noticed that it renders differently in various email clients. The main issue arises in Outlook 2003 where the main picture is offset to the left and the grid boxes vary in height depending on the co ...

Troubleshooting issue with Bootstrap 5 Scrollspy not activating on activate.bs.scrollspy event

Despite trying everything from the documentation, the event is still not functioning properly. However, the list updates when I scroll. Here's what I've done: Added position: relative; to the body. Added data-bs-spy="scroll" data-bs-ta ...

The Jquery slider panel seems to be stuck open even after I switched its CSS orientation from right to left

I am following up on a previous question, which can be found here. After fixing the jQuery code, I decided to change the panel slider to open from the left side instead of the right. I modified the class from "cd-panel from-right" to "cd-panel from-left". ...

I'm having trouble grasping the concept of margin collapse in this particular example

It's clear why the margin collapses to 20px in the first example when there's a border on the outer div. However, it is puzzling how the margin collapses to zero in the second example just by removing the border from the outer div. /*First exam ...

What is the best way to implement a gradual decrease in padding as the viewport resizes using JavaScript

My goal is to create a responsive design where the padding-left of my box gradually decreases as the website width changes. I want the decrease in padding to stop once it reaches 0. For instance, if the screen size changes by 1px, then the padding-left sh ...