"Integrating backgrounds into divs disrupts the overall design aesthetic

One of the challenges I faced was trying to space out the three columns in my Bootstrap row while also splitting each column into two parts. After doing some research, here's the solution I came up with:

<div class="container row h-100 mx-auto" style="margin-top: -60px;">
  <div class="col-sm-4 ">
    <div class="mx-3">
          <div class="" style="width:50%; float: right;">
            <h4>About Us</h4>
            <p>Find out more about our team of working professionals</p>
          </div>
    </div>
  </div>
  <div class="col-sm-4 ">
    <div class="mx-3 rounded">
      <div style="width: 50%; float: left;">
        <i class="fa fa-users" aria-hidden="true"></i>
      </div>
      <div style="width: 50%; float: right;">
        <h4>Our Purpose</h4>
        <p>Come up with some stuff to be put in here</p>
      </div>
    </div>
  </div>
  <div class="col-sm-4 ">
    <div class="mx-3">
      <h4>Our products and services</h4>
      <p>Check out our vast array of products and services that we offer.</p>
    </div>
  </div>
</div>

For reference, you can view how it looks here.

If you're experiencing issues adding a background color to your columns, it could be due to conflicting styles. You may have a CSS class named .card that affects the formatting. This class typically adds a rounded edge and white background to a div, potentially interfering with your desired styling.

To maintain spacing and alignment while adding a background color, consider adjusting the CSS properties within the .card class or creating a separate class specifically for the column backgrounds. By isolating the styling, you should be able to achieve the desired look without any formatting issues.

Answer №1

To begin, I recommend keeping rows inside containers for optimal functionality. When combining .container and .row, be aware that the Bootstrap grid system may not function properly, as rows lack a flexbox container parent.

If you require two internal columns, consider declaring a row with two columns, similar to how you created a three-column outer layout. Using inline styles and floats can counteract the benefits of using Bootstrap's flexbox style grid system:

<div class="rounded">
    <div class="row">
        <div class="col-6">...</div>
        <div class="col-6">...</div>
    </div>
</div>

You can also make use of the predefined .card class to assist with padding:

<div class="row">
    <div class="col-sm-4">
        <div class="card border-0">
            <div class="card-body">
                <div class="row">
                    <div class="col-6"></div>
                    <div class="col-6">
                        <h4 class="card-title">Our Purpose</h4>
                        <p class="card-text">
                            ...
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

To apply a background color to the .card, simply utilize the background color classes:

<div class="card border-0 bg-danger">
    ...
</div>

https://i.sstatic.net/bSKJp.png

Demo: https://jsfiddle.net/davidliang2008/ed8bav14/36/

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

Flow bar for micro-tasks

In my current project, I am faced with the task of organizing a series of 4 mini tasks and displaying to the end user which specific mini task they are currently on. To accomplish this, I have been utilizing image tags for each task. <img>1</img ...

How come jQuery won't let me activate the 'change' event on a radio button?

Click the link below to access the page: Below are the original javascript codes that are functioning correctly: $(document).ready(function(){ $(".open_gene").on('change', function(event) { $('#Gene_field').show(); }); ...

Submitting a Form with Multiple Pages

I'm encountering a challenge that I'm struggling to work through. Initially, we had a professional build our website, but since parting ways with the company, I've taken over site management. While I can handle basic tasks, I lack the expert ...

Equalizing column heights in Bootstrap layouts

It seems like a straightforward issue, but I'm having trouble finding a solution. I am utilizing Bootstrap5 for this project. You can find the complete code here : Due to some problems with Codeply, I have also uploaded it on jsfiddle. https://jsf ...

Customizing Bootstrap modal backdrop with CSS

I'm exploring how to achieve the backdrop effect of the Bootstrap modal without actually having to load a modal. However, I'm struggling to make it work correctly. Can anyone provide insight into the CSS that the Bootstrap backdrop utilizes inter ...

Encountered an unexpected "<" error while using Ajax with MySQL

I am trying to accomplish a simple task - retrieve a table from a MySQL database. Previously, I was using basic MySQL code and it was working fine. However, after switching to MySQLi, I encountered an error: Uncaught SyntaxError: Unexpected token < ...

Building a custom search modal using RenderPartial in Yii

I'm currently working on developing a modal box that will enable users to filter and search through a grid. The main objective is to allow users to retrieve information from one database while simultaneously completing a form in another database. Alt ...

Ways to obtain data in JavaScript function from HTML

Struggling to pass the key from a database query in HTML using PHP to a JavaScript function? You're not alone. The challenge lies in passing the field_id to the updateRecords() JS function through the onClick() event of an HTML button. Previously, se ...

Send information from Node.js to the webpage and populate designated elements (search by either ID or class) on the webpage

After successfully retrieving data from the mongo database using nodejs, my goal is to display this data on a webpage. function requireUser(req, res, next){ //console.log(req.session.username); if (!req.session.username) { res.redirect('/user_un ...

Displaying JavaScript Countdown in PHP Table

I have a database table with multiple fields and I am looking to create a countdown using the integer value from one of the fields (in minutes). How can I loop through and display the countdown for each row in a PHP table utilizing these values, with the a ...

Choose either nth-child or nth-of-type within a nested element

Here is the HTML code snippet: <div class="homepage-body"> <a href="#"> <div class="homepage-item"> <div class="homepage-icon"></div> <div class="homepage-text"> Test1 </di ...

Is there a way to incorporate a responsive side menu using JQuery or CSS3 that can shift the entire page layout?

Hey there, I'm currently trying to incorporate a responsive side menu into my website using either JQuery or CSS3. What I need is a side menu that will smoothly shift the page content when a link is clicked, and also adds a close button (X) to the men ...

Various placements in Internet Explorer, Chrome, and Mozilla Firefox

Currently, I am working on a website project The layout appears to be fine in Internet Explorer and Firefox, but there seems to be an issue in Chrome. Due to the length of the code, it cannot be posted here, so I have included links to the files: HTML: ...

Modify section background color for every iteration in an image carousel

Is it possible to dynamically change the background color of the cd-hero section each time a new image is loaded in a simple slider on the home page? Can this be achieved by storing predefined colors in an array so that different images trigger different b ...

The script fails to work correctly when displaying the data

Last night, I finally cracked the code on how to transfer data from my form on the index page to the content page, and then display the results inside the content div back on the index page. However, a new challenge has emerged. My Javascript function (re ...

Avoiding the overlap of sub-menu items vertically

My nested unordered list acting as a sub-menu has an issue with overlapping list items. It seems like the padding of the links is causing the overlap: ul { padding: 12px 0; list-style: outside none none; } li { display: inline-block; margin-righ ...

Express handlebars does not support client-side javascript

This is a unique template <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>My Amazing Website</title> ...

Why isn't my easypie number displaying on the inside?

I am currently utilizing the easypie plugin, but I am facing an issue where the number is not displaying inside the pie chart. Despite trying multiple solutions, I haven't been able to resolve this. How can I successfully display the number inside the ...

What is the best way to determine the quantity of identical items in the django templating language?

My goal is to create a table that organizes items by type, all retrieved from my database. Currently, I can display the items and their corresponding types without any issues in a table format. However, I want to avoid repeating the same type multiple time ...

Executing the OnChange event of the "Select" feature in Delphi with WebBrowser

In my Delphi project, I am using the WebBrowser component to navigate a HTML page that contains a ComboBox. Is there a way to trigger the OnChange event of the ComboBox? Here is how the ComboBox is structured: <select name="comboname" onchange="Some J ...