What is the best way to enlarge a column contained within a container, allowing an image to spread from the center of the column all the way to the right edge of the page?

I am trying to modify my image within a bootstrap container to extend it to the side while keeping the rest of the layout unchanged. Here is what I currently have: https://i.sstatic.net/Mcukl.jpg. There is a gap on the right side of the image that I want to cover (shown by the green line) without affecting the middle of the column (red line). You can see the visual explanation in this image: https://i.sstatic.net/SdVUZ.jpg

However, I am facing difficulties achieving this with the container. I know I could use container-fluid, but I prefer to stick with the container for consistency in my layout. When using container-fluid, the margins are not aligned as neatly as I'd like them to be.

Any help or advice would be greatly appreciated, as I'm struggling to make this adjustment without messing up the entire layout.

EDIT 1

Here is the code snippet that I forgot to include earlier:

<div class="container">
            <div class="row">
                <section class="col pt-5">
                    <div>
                        <h1>Welcome to</h1>
                        <h1>XE-Designs</h1>
                        <p>Easy furniture rental with white glove delivery & assembly. Currently in NYC, SF, LA, Baltimore, Richmond, and the DC Area!</p>
                    </div>
                </section>
                    
                <section class="col">
                    <img class="img-fluid w-100" src="~/images/barn-images-t5YUoHW6zRo-unsplash.jpg" />
                </section>
            </div>
        </div>

Answer №1

After reading through this explanation, I was able to achieve my desired outcome of breaking the bootstrap container. By reversing the calculations used, I determined the necessary attributes to apply. I sketched it out for myself and arrived at the correct calculation to implement. Below is the html code I utilized:

<div class="container">
            <div class="row">
                <section class="col-md-6 d-flex align-items-center">
                    <div>
                        <h1>Welcome to</h1>
                        <h1>XE-Designs</h1>
                        <p>Easy furniture rental with white glove delivery & assembly. Currently in NYC, SF, LA, Baltimore, Richmond, and the DC Area!</p>
                    </div>
                </section>

                <section class="col-md-6">
                    <div class="css_break_out">
                        <img class="img-fluid w-100" src="~/images/barn-images-t5YUoHW6zRo-unsplash.jpg" />
                    </div>
                </section>
            </div>
        </div>

Here is the css I applied:

.css_break_out {
        width: calc((100% + (100vw - 100%) / 2) + 15px);
        position: relative;
        left: calc(-1 * (100vw - 100%) / 2);
    }

    @@media (min-width: 576px) {
        .css_break_out {
            width: calc((100% + (100vw - 100% - 15px)));
            position: relative;
            left: calc(-1 * (100vw - 100% - 15px) / 2);
        }
    }

    @@media (min-width: 768px) {
        .css_break_out {
            width: calc((100% + (100vw - 200%) / 2) - 15px);
            position: relative;
            left: 0;
        }
    }

If there are any suggestions for improving the css/html provided above, feel free to share them with me and I will make the necessary edits.

Answer №2

Make Changes

To customize your div with the class name row, try incorporating the class d-flex

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5b3934342f282f293a2b1b6e756b65756b673434">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container bg-secondary">
  <div class="row p-2">
    <section class="col pt-5 border border-white">
      <div>
        <h1>Welcome to</h1>
        <h1>XE-Designs</h1>
        <p>
          Simplifying furniture rental with premium delivery & assembly services. Operating in NYC, SF, LA, Baltimore, Richmond, and the DC Area!
        </p>
      </div>
    </section>
    <!-- Apply d-flex and align-items-center for flexbox display and vertical alignment of child elements at center -->
    <section class="col d-flex align-items-center border border-white">
      <!-- For the latest Bootstrap version, use ms-auto and d-block. For older versions, utilize ml-auto.
      Ensure your image is smaller than its container for proper display. If using w-100, it will expand to 100% width -->
      <img class="img-fluid w-75 bg-dark d-block h-75 ms-auto" src="~/images/barn-images-t5YUoHW6zRo-unsplash.jpg"/>
    </section>
  </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

I am looking to implement an animation that automatically scrolls to the bottom of a scrollable DIV when the page is loaded

My DIV is configured with overflow-y set to scroll. .scrolling-div { width: 85%; height: 200px; overflow-y: scroll; } If I have an abundance of content within this div, my goal is for it to automatically scroll to the bottom upon loading the page. I am ...

Recalling the position of the uploaded image within a v-for loop

I am struggling to solve this issue. Currently, I am utilizing Vue.js in an attempt to construct a dashboard where users can upload up to five images of visitors who are authorized to access a specific service provided by the user. Below is the code snip ...

A handy feature of HTML5 is the dataset attribute, which

Is there a way to restrict the height of the dataset dropdown list in HTML? When using <input list="datalist"> with numerous elements, some might not be visible. Is it possible to limit the size of the list and enable vertical scrolling to display al ...

Utilizing CSS to create dynamic 3D cube transformations

Exploring the realm of CSS 3D transforms to showcase cubes and cuboids featuring cross-sections has been my current venture. In this endeavor, I'm aiming at compatibility with Chrome, Firefox, and MSIE 11. It has come to my attention that in order to ...

Unforeseen outcomes discovered by stacking one div over another, all without relying on z-index

My current project involves two stacked divs, each measuring 100px by 100px. The bottom div includes a black border on top, as shown in this example. <div id="top"></div> <div id="bottom"></div>​ div { width: 100px; height ...

I'm new to Angular and I'm wondering how to close the panel by clicking on the 'x' button and also by clicking on the screen. Can anyone help me with this

Below is the HTML code I use for my button: <button class="btn btn-outlined " ng-click="vm.showCommentBox1()">Notify All</button> <div class="comment-box custom saveAll" ng-if=""><div class="panel panel-default"> ...

Having trouble with a basic Div/CSS layout? Not turning out how you expected

While experimenting with CSS, I encountered a challenge in creating a simple horizontal stack of words. It seems impossible to align the content of one div in the center while the other div is empty. For example, I tried doing this in Chrome and here is t ...

A guide to adjusting the width without affecting the td element

Currently, I am facing a challenge while coding in HTML. I am trying to create a table with a header (time range) that fits on a single line without affecting the width of the td elements. Below is the code snippet: <table style="border:1px solid #8c ...

Top align a flexbox layout with three columns

I am facing a challenge in aligning my 3 columns at the top with multiple "rows". When I apply the CSS property align-items: flex-end;, I achieve the desired layout, but the elements are aligned at the bottom. However, if I attempt to use align-items: flex ...

Tips for positioning a picklist field dropdown on top of a lightning card in Lightning Web Components

Attempting to resolve an issue with CSS, I have tried adding the following code: .table-responsive, .dataTables_scrollBody { overflow: visible !important; } However, the solution did not work as expected. Interestingly, when applying a dropdown pickli ...

Making a secure connection using AJAX and PHP to insert a new row into the database

Explaining this process might be a bit tricky, and I'm not sure if you all will be able to assist me, but I'll give it my best shot. Here's the sequence of steps I want the user to follow: User clicks on an image (either 'cowboys&apos ...

Automatic Clicks in the Chrome Console

I've come across a website that requires me to click on multiple elements scattered throughout the page Here is the code for one of the elements: <span class="icon icon-arrow-2"></span> Is there a way to provide me with the console comm ...

Adjusting the transparency of the background color seamlessly without the need for an image

After creating a div element with a green background color, I am looking to progressively change the opacity of the color from top (darkest green) to bottom (lightest, white). Is there a CSS-based way to achieve this effect without resorting to using an ...

Tips for generating a document and adding information from an HTML webpage?

My desktop has an html file which requires input. How can I save this input to a file on my computer? Do I need to use a different language like python or javascript, and if so, how do I do it? Additionally, is there a way for javascript to launch an app ...

Leverage the power of jQuery to merge the values from two input fields into a third input

Currently exploring jQuery and attempting to combine the contents of box one and box two to display them in another input field separated by ||. For instance, if "hello" is entered in the first text box and "you" in the second box, I want to show hello||y ...

What is the best way to extract pricing information from Udemy?

Important: I haven't been able to find a relevant solution in similar questions. How can I extract prices from Udemy using web scraping? Scraping Data From Udemy's AngularJs Site Using PHP How do I obtain promotional prices using the Udemy API ...

Is it possible to adjust the zoom on my website so that it adapts to the user's higher resolution if my website layout is initially set for 800x600 resolution?

Apologies for the confusion in my previous question. I am not looking to alter the user's browser settings but rather focus on optimizing my website layout for the most common resolution size. Ideally, I want my page to adjust and zoom in if the user& ...

Retrieve information from a MySQL database and integrate it into a different application

This php script is used to generate a table with a "book" button next to each row. The goal is to extract the values of "phase" and "site" from the specific row where the "book" button is clicked, and transfer them to another form (in "restricted.php") fo ...

An issue occurred when retrieving the input value during a (change) event within a nested *ngFor loop in Angular

Within my table, I have implemented a nested loop using the *ngFor directive: <tbody> <tr *ngFor="let dept of salesTarget; let i = index"> <td>{{dept.dept}}</td> <td *ngFor="let month of monthList; ...

What could be causing Media-Query to fail when using the max-width media feature?

I recently added a max-width media feature to my code, but for some reason, the colors aren't changing when the width is less than 300px. I've been trying to inspect elements on my laptop to troubleshoot the issue. Additionally, I've made su ...