Ways to modify the background shade of a bootstrap column

I am looking to customize the background color of a single column within a bootstrap row, along with applying padding to the row. Please refer to the screenshot provided below for clarification.

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

    <div class="container event-details-wrapper">
      <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
      <h3 class="event-tag tooltip" tooltip="Click here to copy the event code" @click.stop="copyEvent($event)">#{{event.code}}</h3>
      <UserWidget :repeatEvent="true" :email="event.name" :title="event.duration" :action="goToEvent"/>
    </div>
    <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12" style="display:flex;">
      <div class="QnA-Details"></div>
      <div class="Sub-QnA-Details">
        <p>Q&A</p>
        <span>3000</span>
      </div>
      <div class="Form-Details"></div>
      <div class="Sub-Form-Details">
        <p>Forms</p>
        <span>06</span>
      </div>
      <div class="Polls-Details"></div>
      <div class="Sub-Polls-Details">
        <p>Polls</p>
        <span>02</span>
      </div>
      </div>
      <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<div class="event-actions-wrapper" v-if="!isExpired">
      <ul>
        <li><div class="event-action download tooltip" tooltip="Project event" @click.stop="download"></div></li>
        <li><div class="event-action project tooltip" tooltip="Project event" @click.stop="project"></div></li>
        <li><div class="event-action phone tooltip" tooltip="Project event" @click.stop="phone"></div></li>
      </ul>
    </div>
      </div>
    </div>
    </div>

My current code setup is shown above. However, I am encountering an issue where the padding area of the specific column is not changing along with the background color.

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

What would be the best approach to fulfill this requirement within the given scenario? I opted for utilizing bootstrap to ensure responsiveness across various devices including mobile.

Answer №1

After reviewing your code, I made a direct change to the background of the last column by adding the following:

style="background: red;"

It appears to be functioning correctly. If it is not working for you, there may be some missing CSS.

For demonstration purposes, I added background: grey; to the row.

DEMO:

.row{
  background: grey;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a7a657a7a6f782460794a3b243b3c243b">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

<div class="container event-details-wrapper">
  <div class="row">
    <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
      <h3 class="event-tag tooltip" tooltip="Click here to copy the event code" @click.stop="copyEvent($event)">#{{event.code}}</h3>
      <UserWidget :repeatEvent="true" :email="event.name" :title="event.duration" :action="goToEvent"/>
    </div>
    <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12" style="display:flex;">
      <div class="QnA-Details"></div>
        <div class="Sub-QnA-Details">
          <p>Q&A</p>
          <span>3000</span>
        </div>
        <div class="Form-Details"></div>
        <div class="Sub-Form-Details">
          <p>Forms</p>
          <span>06</span>
        </div>
        <div class="Polls-Details"></div>
        <div class="Sub-Polls-Details">
          <p>Polls</p>
          <span>02</span>
        </div>
      </div>
      <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12" style="background: red;">
        <div class="event-actions-wrapper" v-if="!isExpired">
          <ul>
            <li><div class="event-action download tooltip" tooltip="Project event" @click.stop="download"></div></li>
            <li><div class="event-action project tooltip" tooltip="Project event" @click.stop="project"></div></li>
            <li><div class="event-action phone tooltip" tooltip="Project event" @click.stop="phone"></div></li>
          </ul>
        </div>
      </div>
    </div>
  </div>

Answer №2

Is this the type of solution you had in mind?

<style>
.background {
  padding: 15px;  /* Just an illustration of padding */
  background: lightgrey; /* Just an example color */
  background-clip: padding-box;  
}
</style>

The key aspect here is background-clip: border-box;. This is what allows the background color to expand to the border of the specified area. You can also include the border itself by using: background-clip: border-box;

Below, I have added the background class to the div element:

<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 background">
  <div class="event-actions-wrapper" v-if="!isExpired">
      <ul>
        <li><div class="event-action download tooltip" tooltip="Project 
        event" @click.stop="download"></div></li>
        <li><div class="event-action project tooltip" tooltip="Project 
        event" @click.stop="project"></div></li>
        <li><div class="event-action phone tooltip" tooltip="Project event" 
        @click.stop="phone"></div></li>
      </ul>
  </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

Aligning a child div within a parent div using HTML/CSS where the child div takes up 30% of the parent div and

Can anyone help me figure out why these two INPUT elements aren't aligning next to each other? I appreciate any assistance you can offer! <STYLE> html, body { width: 100%; height: 100%; margin: 0px; padding: 0px; } </STYLE& ...

I'm having trouble getting this button and icon to align properly. How can I fix this misalignment

Take a look at the HTML code snippet I'm currently working on... <div id="projects"> <H1 class="projects">PROJECTS</H1> <div class="box"></div> <div class="box"></div> <div class="box"></ ...

Having trouble with the responsive design not functioning properly?

Having trouble with mobile view in my simple HTML Bootstrap code. Everything looks fine in desktop view but not in mobile. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < ...

What is the best way to allow wider list items to overflow their absolutely positioned container?

My challenge involves a list that is dynamically populated, and I require it to be wider than its absolutely-positioned parent (specifically a custom <select> element implementation). #wrapper { position: relative; border: 1px ...

When attempting to select an option from the dropdown menu, I encounter an issue where the

My code is not behaving as expected. Whenever I click on the child elements, the dropdown changes to display: none. I am encountering an error when clicking on the input frame and displaying:none. How can I resolve this issue? I would like to be able to ...

HTML text-indent is a way to add extra space to

I cannot understand why my text is not indenting properly. At the very bottom left corner, the "Educational Specifications" text is enclosed within a p element as follows: <p style="text-indent: 3em">Educational Specifications</p> Why doesn& ...

Is it possible to align the modal based on the mouse's position or a specific element?

Recently, I completed a React project that utilizes an API to search for movie titles. The project returns a list of movies corresponding to the user's search query. Everything seems to be working fine up to this point. However, I encountered an issu ...

Issue with the overall HTML design

The placement of the banner is exactly where I want it to be, however, the boxes using jQuery masonry are overlapping it. I'm not sure what I did wrong here. Any suggestions or insights on how to fix this issue? Example HTML Code: <script type="t ...

The alignment of the website design is off

I'm in the process of creating a custom template for my website and everything was going smoothly until I encountered an issue with the news bar placement. Instead of appearing below the navbar and welcome message bar, it's showing up above the n ...

The connection between the layout of dropdown menus and the way data is handled in forms

I have discovered three different methods for creating dropdowns that can be used in forms: 1) Utilizing HTML with "form-dedicated" attributes such as select and option value="" 2) Implementing the Bootstrap framework with div classes like "dropdown", Butt ...

The new button placed on a <div> was not initialized to trigger my greasemonkey functions

Recently, I implemented a button via GreaseMonkey: var input = document.createElement('input'); input.type = 'button'; input.value = 'Off'; input.onclick = turnTheWheelsofTime; Initially, the button functioned flawlessly whe ...

Add a file to the input field using JavaScript and the input type="file"

I am facing the challenge of sending a file (up to a few MB) generated by JavaScript to a server using POST (not ajax POST). I am wondering how I can add a file to an input type="file" using JavaScript. After checking Pre-Populate HTML form file input, it ...

Implemented a solution to ensure the menubar remains fixed when zooming in and out

When zooming in and out on a webpage, the menu does not stay fixed to the header image shown in the figure below: The CSS code for this issue is as follows: #navmenu{ z-index:99999; margin-top:40px; position:absolute; width:100%; m ...

Discover the concealed_elem annotations through the power of JavaScript

As I work on my new website, I am struggling with narrowing down the web code. I came across a solution that seems fitting for what I need, but unfortunately, I can't seem to make it work: I attempted the non-jQuery solution, however, I must be missi ...

How can I make a div blur as I scroll through the page

How can I make each item in my timeline focused one at a time as the user scrolls, instead of having all items in focus simultaneously? Any ideas or suggestions would be appreciated. Here is my fiddle and here is my code $(document).ready(function(){ ...

CSS Float issue on resizing: avoid element displacement due to margin or padding (responsive layout)

Having an issue that I need help with: My header includes a menu, news sliding with flexslider, and a search input: The problem occurs when I resize the browser manually or reload it with a smaller width; the right element jumps down, causing a pushdown ...

Ways to modify the data within a column for every row in a table without relying on props in Vue.js (specifically Element-ui)

I've been stuck on this issue for quite some time now. I've created a table with 3 columns, and for the first two columns, I can easily display the contents of each row using the prop property. However, for the third column, I need to display inf ...

Continuously animate a series of CSS properties

Here's the code snippet I'm working with: @keyframes ball1 { 0% { transform: translateX(0px); opacity: 0%; } 50% { opacity: 100%; } 100% { transform: translateX(120px); opacity: 0%; } } @keyframes ball2 { 0 ...

Is it possible to modify the class attribute of an HTML element in PHP upon clicking an input?

In this assignment, I am restricted to using only PHP and cannot incorporate JavaScript. Currently, my code is set up to detect a post from an input type="submit" and then check for empty or filled text inputs. The code currently echoes text based on the c ...

HTML5's drag-and-drop feature, including nested targets, allows for intuitive and interactive user

I'm currently implementing HTML5 drag and drop functionality. I have a parent div that is droppable, and inside it, there is another child div that is also droppable. <div id="target-parent"> <div id="target-child"></div> </d ...