`The title doesn't reach the bottom of the container`

I'm experiencing an issue with the heading banner on my website. When viewed on a collapsed screen, it looks great with responsive design (see capture below) thanks to setting the width to auto and utilizing Bootstrap 4.

https://i.sstatic.net/bsKg0.jpg

However, on full-screen resolution, the heading background fails to extend to the end of the div despite my attempts to remove padding. See image for reference.https://i.sstatic.net/7xFZq.jpg

Here is the snippet of my HTML:

<!--browse by category section-->
    <section id="category">
        <div class="card-header text-center">
            <h4 class="card-title">Browse Workouts by Category</h1>
        </div>
        <div class="row btn-warning">
            <div class="col-sm-2 bg-primary" id="cardio">
                <h1 class="text-center">Cardio</h1>
            </div>
            <div class="col-sm-2 bg-primary">
                Hi
            </div>
            <div class="col-sm-2 bg-primary">
                Hi
            </div>
            <div class="col-sm-2 bg-primary">
                Hi
            </div>
            <div class="col-sm-2 bg-primary">
                Hi
            </div>
            <div class="col-sm-2 bg-primary">
                Hi
            </div>
        </div>
    </section>

Additionally, here is the relevant portion of my CSS:

/*--------------*/
/*---CATEGORIES-----*/
/*--------------*/

#cardio {
    background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('../img/users/pexels-photo-460520.jpeg') no-repeat;
    background-size: cover;
    height: 300px;
}

#cardio h1 {
    margin-top: 100px;
    height: 100px;
    width: auto;
    padding-top: 25px;
    color: #fff;
    background: linear-gradient(rgba(93,139,229,0.7), rgba(93,139,229,0.7));
}

Answer №1

Make sure to include the container div before the row. To make the title full width, add negative margin to override the padding of the outer class col-sm-2.

It's best to avoid altering the styles of bootstrap classes as it can potentially disrupt your layout.

/*--------------*/


/*---CATEGORIES-----*/


/*--------------*/

#cardio {
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('../img/users/pexels-photo-460520.jpeg') no-repeat;
  background-size: cover;
  height: 300px;
}

#cardio h1 {
  margin-top: 100px;
  height: 100px;
  margin-left:-15px;
  margin-right:-15px;
  padding-top: 25px;
  color: #fff;
  background: linear-gradient(rgba(93, 139, 229, 0.7), rgba(93, 139, 229, 0.7));
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<!--browse by category section-->
<section id="category">
  <div class="card-header text-center">
    <h4 class="card-title">Browse Workouts by Category</h1>
  </div>
  <div class="container">
    <div class="row btn-warning">
      <div class="col-sm-2 bg-primary" id="cardio">
        <h1 class="text-center">Cardio</h1>
      </div>
      <div class="col-sm-2 bg-primary">
        Hi
      </div>
      <div class="col-sm-2 bg-primary">
        Hi
      </div>
      <div class="col-sm-2 bg-primary">
        Hi
      </div>
      <div class="col-sm-2 bg-primary">
        Hi
      </div>
      <div class="col-sm-2 bg-primary">
        Hi
      </div>
    </div>
  </div>
</section>

Answer №2

Here's a solution for you:

 .row, .col {
  padding: 0;
  margin: 0;
}

#cardio {
   padding: 0;
}

#cardio h1 {
   width: 100%;
}

Leave everything else unchanged

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

Arranging Radio Buttons in a Row and Aligning a Radio Input Group Side by Side using Bootstrap 5

"I'm having a little issue with aligning radio buttons and a radio input group inline on the same line. The input group keeps moving to a new line for some reason. Can anyone help?" Below is the code snippet: <div class="d-flex flex ...

Issues with Jquery's Slice, Substr, and Substring functionalities

I need to divide the content into two separate sections. Unfortunately, the first variable (summarySentence1and2) is not capturing the desired result, while the second variable (summarySentanceOthers) is storing all of the content from the source field. I ...

Is it possible to animate captions and slides individually within a Bootstrap 5 carousel?

Beginner coder here, testing my skills with a self-assigned task. I've created a carousel using Bootstrap 5 with three slides, each containing two lines of captions. As the slides transition, the captions move in opposite directions—up and down. Ho ...

javascript include new attribute adjustment

I am working with this JavaScript code snippet: <script> $('.tile').on('click', function () { $(".tile").addClass("flipOutX"); setTimeout(function(){ $(".tile-group.main").css({ marginLeft:"-40px", widt ...

The only functioning href link is the last one

Currently, I am in the process of constructing a website using HTML and CSS. My goal is to create a white rectangle that contains 4 images, each serving as a clickable link redirecting users to different sections on the page. The issue I am facing is that ...

When an anchor surrounds a div tag, white borders will appear

Lately, I've encountered an unusual issue. My buttons are created using div tags with rounded edges and border colors defined in the CSS. To link them to specific destinations, I encapsulated them within <a> tags. The problem arises when the li ...

Dividing image styles within css

I am trying to incorporate 4 arrow images into a CSS class (up, down, right, left). I started with a basic arrow css class: .arrow { background-repeat: no-repeat; background-position: center; } Next, I created subclasses like: .arrow .up { ...

What is the best way to align a button directly beside an input field using Bootstrap's columns and grid system?

Is it possible to place a button right next to an input box while utilizing the bootstrap columns/grid system? The Label is set to 2, EditorFor div to 4, and the input div to 6. When I reduce the EditorFor div to 3, it moves the input/button div closer tog ...

How to retrieve an array from an object using React

In the context of my React application, I have a function called Query2 within a file named service.ts. The structure of this function is as follows: interface Result { products: number[]; } export async function Query2(molsSdf: string): Promise<Res ...

Experiencing an issue of receiving an undefined value while attempting to retrieve a value from an input box

HTML: <input value='Rename' type='button' onclick='RenameGlobalPhase({$row['id']});' <span id='renameGlobalPhase{$row['id']}'>" . $row['phase'] . "</span> Below you wil ...

How to center an HTML header

Currently working on a one-page scrollable website, aiming to have the first page consist of a navbar, image, and header. The challenge I'm facing is centered around aligning the header vertically. Although I managed to center it horizontally, the ver ...

Issues arise when inline elements are not behaving correctly when placed alongside inline-block elements

Among the various types of HTML elements, inline and inline-block elements have their differences. One such difference is that inline elements don't support margin-top or margin-bottom properties like inline-block elements do. However, in a specific e ...

Customize your Bootstrap 4 navbar to align on the right with a button that remains visible on mobile devices

I'm working on setting up a navbar with three elements. I want to have a left-aligned brand, a group of right-aligned links that will collapse on smaller screens, and an additional button that stays visible at all times. To achieve the alignment of t ...

Updating the background image of individual users in a Laravel blade template in real-time

I'm working on an application with different types of users, and each user has a unique background image for their wall similar to Facebook. However, I am struggling to figure out how to dynamically change the background image for each user. The image ...

Customize the style of the title bar in a jQuery dialog

Is there a way to change the title bar color of specific jQuery dialogs without affecting all of them? I tried using the property dialogClass:"myClass" in certain dialogs, but it only changes the body of the dialog. Any suggestions would be greatly apprec ...

Implementing AngularJS to display different divs according to the selected value

I am attempting to utilize the value of an HTML select element to toggle the visibility of specific div tags using AngularJS. Below is the code snippet I have been working with: <body ng-app="kiosk" id="ng-app" > <div class="page" ng-controll ...

exchanging the positions of two animated flipdivs

Hey there! I'm facing a little challenge with my two divs (let's call them div1 and div2). One of them has a flip animation on hover, while the other flips on toggle click. My goal is to swap these two divs by dragging and dropping them. I' ...

Exploring Ember Octane (version 3.22 and above): benefits of using {{on 'click' this.function}} over traditional onclick={{this.function}} method

When working with Ember Octane, there are two different ways to attach a function to an event in an hbs file. The first way is the EmberJS approach: {{on 'click' this.function}} Alternatively, you can use the classic HTML method: onclick={{this ...

Construct a Product Showcase Page" (FreeCodeCamp) - Issue "Incurred upon clicking a .nav-link button in the navigation panel

Hi there! I've been working on a page programming task, but I'm having trouble with the "№5 “When I click a .nav-link button in the nav element, I am taken to the corresponding section of the landing page.” error. Can anyone help me figure ...

Selenium in Python does not have the capability to extract innertext

I am attempting to extract the text from a specific webpage's title. The HTML tag I need to target is as follows: <h1 class="d2l-page-title d2l-heading vui-heading-1 bsi-set-solid">TEXT HERE</h1> I have confirmed that my XPATH is accurat ...