Background image not adhering to the page width as expected within the Bootstrap framework

I feel like I'm losing my mind.

Currently, I am in the process of designing a section that consists of four photo boxes - two at the top and two below.

In order to achieve this layout, I have turned to utilizing Bootstrap.

Unfortunately, this particular section is causing chaos in my design, and I seem to be stuck without any solution. I simply cannot identify where the mistake lies.

It's worth noting that the boxes on the right side are not adhering to the width of the page as they should.

Although I've configured padding: 0; with Bootstrap, the issue still persists.

HTML:

        <div class="row">
            <div class="col-md-6">
                <div class="booking-photo booking-1 wow bounceInLeft">
                </div>
            </div>
            <div class="col-md-6">
                <div class="booking-photo booking-1 wow bounceInLeft">
                </div>
            </div>
            <div class="col-md-6">
                <div class="booking-photo booking-1 wow bounceInLeft">
                </div>
            </div>
            <div class="col-md-6">
                <div class="booking-photo booking-1 wow bounceInLeft">
                </div>
            </div>
         </div>

CSS:

.booking-2 {
  background: #000;
  position: relative;
  z-index: 3;
}
.booking-2 .col-md-6 {
  padding-top: 0px;
  padding-right: 0px;
  padding-bottom: 0px;
  padding-left: 0px;
}
.booking-2 .booking-photo {
  display: block;
  height: 320px;
  background-color: #373c40;
  background-position: 0% 0%;
  background-repeat: repeat;
  background-attachment: scroll;
  text-align: center;
  text-decoration: none;
  background-position: 50% 50%;
  background-size: cover;
  background-repeat: no-repeat;
}
.booking-2 .booking-1 { background: url('../images/capa.png'); }
.booking-2 .booking-2 { background: url('../images/capa.png'); }
.booking-2 .booking-3 { background: url('../images/capa.png'); }
.booking-2 .booking-4 { background: url('../images/capa.png'); }

Link to Example

Answer №1

<div class="row">
        <div class="col-md-6">
            <div class="booking-photo booking-1 wow bounceInLeft">
            </div>
        </div>
        <div class="col-md-6">
            <div class="booking-photo booking-1 wow bounceInLeft">
            </div>
        </div>
 </div>
 <div class="row">
        <div class="col-md-6">
            <div class="booking-photo booking-1 wow bounceInLeft">
            </div>
        </div>
 </div>
 <div class="row">
        <div class="col-md-6">
            <div class="booking-photo booking-1 wow bounceInLeft">
            </div>
        </div>
        <div class="col-md-6">
            <div class="booking-photo booking-1 wow bounceInLeft">
            </div>
        </div>
 </div>

I suggest moving the 3rd and 4th images to a separate row for better organization.

Answer №2

Check out my solution

I made a couple of changes

  • I grouped the last two images in a new <div class="row">
  • I added two custom classes to the CSS for the desired outcome

Previous code removed

.booking-2 .col-md-6 {
  padding-top: 0px;
  padding-right: 0px;
  padding-bottom: 0px;
  padding-left: 0px;
}

New code added

        .leftColumn {
            padding-right: 0px;
        }
        .rightColumn {               
            padding-left: 0px;

View the updated Fiddle

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

Dynamic column group in Datatable - toggle visibility based on user selection

In my application, I am utilizing Jquery datatable with a table that includes the following columns: Name, Office, A1, B1, Diff1, A2, B2, Diff2, A3, B3, Diff3, A4, B4, Diff4 Additionally, there is a select box containing the options: 1. All 2. Diff1 3. D ...

Passing a variable to the render method in a PDF document

I'm currently working on a project with Django where I need to convert an HTML monthly report into a PDF. The data for the report is retrieved from a database based on the selected month. I am facing an issue in sending the selected month from the HTM ...

Stacking two divs for the team section layout

Although I'm new to this, I've been struggling to achieve a specific layout for a team page. My goal is to display a picture on the left side and text on the right for each team member. The design includes the person's name, title, and a set ...

tips and tricks for adding content to json with the help of jquery/javascript

Is it possible to include text in a JSON array using jQuery or Javascript? Assuming that there is data in the following format: A list of numerical codes stored in a text file as 123, 456, 789 I am looking to convert them into a JSON array using JavaScr ...

Create a JavaScript and jQuery script that will conceal specific div elements when a user clicks on them

Within my navigation div, there exists another div called login. Through the use of JavaScript, I have implemented a functionality that reveals additional divs such as login_name_field, login_pw_field, register_btn, do_login_btn, and hide_login upon clicki ...

Leveraging jQuery to extract the value from a concealed form field

Seeking assistance with a jQuery issue... I am attempting to use jQuery to retrieve the values of hidden fields in a form. The problem I am facing is that there are multiple forms displayed on the same page (result set items for updating), and the jQuery ...

Exploring the getJSON function within jQuery

{ "Emily":{ "Math":"87", "Science":"91", "Email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d6f7e767c51767b727e737f764f747879">[email protected]</a>", "City":"Chicago" }, "Sa ...

What is the proper way to insert a line break within a string in HTML code?

Trying to simplify my code, I've turned to using Nunjucks to pass a group of strings to a function that will then display them. This is what it looks like: {% macro DisplayStrings(strings) %} {% for item in strings %} <div>{{ item.strin ...

The Ajax request returned empty data

Is there a problem with retrieving data based on user selection from a drop-down menu in an MVC 5 controller? I am able to capture the selected value, but when passing it to the controller, the data appears to be null. Any suggestions or solutions? jQuery ...

JQuery AJAX click event not triggering

I'm currently working on a project to create a dynamic website where users can update text fields directly from the site. However, I've encountered an issue on the 'admin' page where nothing happens when the button is pressed to set the ...

When using the POST method with npm http-server, an error 405 is thrown

I'm attempting to send an Ajax request to execute a php file on a local http server. However, the browser console shows Error 405: method not allowed. Even after trying solutions from similar questions and enabling CORS on the http-server, I still ca ...

Determine the exact scroll position needed to reveal the element when scrolling in reverse

I'm looking for a way to make my div disappear when I scroll down and reappear immediately when I start scrolling back up. Currently, it only works when I reach a certain position instead of taking effect right away. I need assistance in calculating t ...

Create a typing effect in Javascript that mimics the user's input

Trying to simulate a typing effect with the sentence extracted from user input using JavaScript, but encountering some issues. Successfully capturing and displaying the input in the console with console.log(), however, incorporating the typing effect func ...

Tips for activating an HTML input field using Javascript

I am currently using localStorage to store a string input by the user as a title, which will be saved for future visits. I would like to implement a button that allows the user to delete the displayed text (from localstorage) and enables the input field fo ...

What could be the reason for the malfunction of my checkbox styling?

I have designed custom checkboxes and radio buttons with CSS styling as shown below: input[type="checkbox"]:checked + label:after, input[type="checkbox"][checked="checked"] + label:after, input[type="radio"][checked="checked"] + label:after, input[type="r ...

Submitting Files with jQuery AJAX in the ASP.NET MVC Framework

Currently, I am working on an application that requires me to upload a file using AJAX. I have implemented the jQuery.form library for this purpose, but strangely, when the action is triggered, the controller receives an empty list of files. Below is the H ...

The Kenburn zoom image effect fails to function

I want to implement a zoom effect on an image using the Ken Burns effect when it is clicked. However, the code I have written does not seem to be working as expected. Here is the code snippet: $(document).ready(function () { $('.kenburns').on( ...

Simplified jQuery function for multiple div mouseover operations

Uncertain about the accuracy of my title. Due to certain reasons, I need to assign different IDs for the class, as it only detects ID and not class when hovered over. Therefore, I have created a CSS version where the opacity of a specific div will change t ...

Is it possible for me to include additional fields in a vuetify calendar event?

Is there a method to incorporate additional fields, such as a description, in addition to the name and start/end time for an event on the v-calendar's day view? ...

Looking for a reliable tool to check your CSS classes and tidy up your code effectively?

It seems like a common issue with a straightforward solution. I have numerous CSS selectors scattered across various files, many of which may be unnecessary and a directory full of HTML files. My goal is to identify all redundant selectors in my CSS within ...