Container beyond div

Having an issue with the div extending beyond the container in Bootstrap 4. When a green div reaches the edge of the page, instead of being cut off it causes a horizontal shift in the page layout. How can this be avoided?

Appreciate any assistance.

Live example: https://jsfiddle.net/Cedec/mu2f0whr/

#section2 img {
  float:right;
}

#section2 {
  margin-top:100px;
}

#section2 h2 {
  color: #323232;
  font-size: 70px;
  font-weight: 800;
  float: left;
  line-height: 80px;
  margin-top: 70px;
}

#section2 p{
  color: #494e53;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.5;
  float: left;
  margin-top: 30px;
}


.txt2 {
  margin-left: 50px;
}

.bg2{
  background-color: #00a998;
  height: 320px;
  z-index: -5;
    margin-top: -550px;
    margin-left: 100px;
}
<section id="section2">
      <div class="container">
        <div class="row">
          <div class="col-lg-5">
            <img src="https://image.ibb.co/hGq0Rd/111.png" alt="">
          </div>
          <div class="col-lg-7">
            <div class="txt2">
            <h2>Lorem ipsum dolor sit amet, consectetur</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore ...
            
          </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-12 bg2"></div>
        </div>   
      </div>
    </section>

Answer №1

It seems like the issue arises from you overriding the margins of col-lg-12, which disrupts its intended functionality. To fix this, make sure to add your 'bg2' class as a child of the col-lg-12 div and apply a position: relative to ensure it stays in the background.

https://jsfiddle.net/mu2f0whr/6/

Answer №2

By applying the CSS property overflow: hidden to the element with the ID of #section2, any content that exceeds the boundaries of the container will be concealed.

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

Troubleshooting jsPDF problem with multi-page content in React and HTML: Converting HTML to PDF

I need to convert HTML content in my React application into a PDF file. My current approach involves taking an HTML container and executing the following code snippet: await htmlToImage .toPng(node) .then((dataUrl) => { ...

The printed PDF of a webpage does not display HTML table background colors in Chrome or Firefox

Is there a way to change the colors of table cells in an HTML table when exporting to PDF? I'm creating content dynamically that includes background-color: #ffffff (or red) and showing it on a webpage, but the cell backgrounds appear as white in the P ...

Column with a set width in Bootstrap

Is it possible to create a fixed width right column in Bootstrap while keeping the left column responsive? I am currently working with Bootstrap 2.3.2 https://i.stack.imgur.com/xOhQo.png (source: toile-libre.org) I want the right column to maintain it ...

Tips for securely using PHP Mailer with your SMTP credentials

Forgive me for my lack of experience, but I'm in the learning process! I'm struggling to understand how my credentials will remain secure when using PHPMailer for a contact form on my website. When entering your credentials in the SMTP Paramete ...

How can I eliminate the empty spaces around a bar chart in Kendo UI?

Struggling to eliminate the extra space surrounding the Kendo UI chart below. Could this be due to a gap or spacing issue? The goal is to create a single-line bar chart with only grey appearing on the right side. Access JSFiddle Codes Here $(doc ...

Using JavaScript to dynamically retrieve element IDs

Within the content on my page, there are multiple tables displaying product information along with their respective authors. Additionally, there is a div that contains hyperlinks for each author. Currently, I am linking the authors' names to hyperlink ...

Change the color of the border to match the background color

I have a parent container with a unique background color. Inside the parent container, there is an unordered list (ul) with multiple list items (li), each having a distinct color and a brighter border color. Now, I am looking to extract the border color of ...

Tips for effectively passing a parameter in @url.Action

I stumbled upon this piece of code: <button type="button" class="btn btn-inverse btn-danger" onclick="@("window.location.href='" + @Url.Action("ActionName", "ControllerName") +"'");"> Link </button> for redirecting- it works gre ...

Is there a way for me to display an alert notification when a website requests access to additional storage on my computer?

Is there a way to set up an alert notification in Internet Explorer when a website requests additional storage on your computer? The notification would ask: Do you want to grant permission for this website to use additional storage on your computer? ...

iOS is not receiving JSON data in the response headers

I am currently utilizing the CocoaHTTPServer for establishing my server connection. However, I encountered an issue with retrieving JSON data in the header file of my HTML page (web client). Here is the code snippet : HTML Page : endAPSession: funct ...

Seamless infinite background scrolling on the canvas without any disruptions

In my HTML5/JS project, I have implemented infinite background scrolling using multiple canvases. The challenge I am facing is that while the animation is smooth after rendering, there is a quick hiccup when transitioning to the next frame due to the need ...

The difference between see-through shades and rgba(0,0,0,0)

What are the primary benefits of using: background-color: rgba(0,0,0,0); over: background-color: transparent; ? ...

The shade of gray on Google Maps is distinctive

Why is my Google Maps script gray when the page loads? When I inspect the elements, it seems like it's due to resizing. Can anyone help me with this issue? Thanks in advance for any assistance. Below is the HTML code for the map which is included with ...

Refreshing Django HTML table dynamically upon database updates

Currently, I have an HTML table set up using a Django template to showcase data from my database. I am looking to ensure that this table remains updated in real-time whenever the database undergoes changes. Despite my research efforts, there is limited inf ...

Issue with positioning Bootstrap tooltip on the right side causing it to not display correctly

Currently, the tooltip I have is functioning properly: However, my main requirement is to align it to the right. So, when I use .pull-right, it appears like this: This is the HTML code snippet: <div class="wrapper">Login <span rel= ...

What is the best way to retrieve a modified HTML input field in CodeIgniter PHP?

I am using a CodeIgniter PHP website with a form for users to add and edit products. The editing process is functioning correctly, here is the code for editing a product: View: <form action="" method="post" enctype="multipart/form-data"> < ...

unable to view the contents of the template using the directive

I am facing an issue with the Directive, as it is not adding an element to the Template. This directive has been included in the .html file. There are no errors being displayed in the console. directive.js: app.directive('myDirective', function ...

Personalized Firefox Scrollbar - Rounded Corners

I have successfully customized the default CSS of browser scrollbars for Chrome and Edge, but I am facing issues with Firefox. Is there a way to sync the scrollbar styling in Firefox with Chrome and Edge? Currently, I am unable to apply border radius to th ...

In Chrome, there is a conflict between the screen width when using `position: absolute` and `position: fixed` if there is vertical

I'm in the process of developing a website with a video banner set to fixed positioning in the background, and a div that has absolute positioning covering part of the video on the bottom half. However, I've encountered an issue - when I add this ...

Is it possible to use the Stop Button on the HTML5 Audio Tag to halt a live MP3 stream

Is there a way to add a stop button as well? Currently, I have play and pause buttons, but the stop function doesn't truly clear the music buffer in the browser; it just stops playback without resetting to the beginning. This is fine for MP3 files but ...