Is there a way to prevent the contents of my div from overflowing beyond my other div?

Hey there! I'm fairly new to this whole web design thing, only a few months in.

Currently, I'm in the process of creating a website for my school.

However, I've hit a bit of a snag with different div containers holding various parts of my page.

First off is .BodyBackground, which contains my background image.

Within that, I have .allContent, serving as the main container for the entire webpage.

Inside .allContent, we have .LeftGroup, .MiddleGroup, and .RightGroup— three separate divs designed to house different styles of text/information.

At the bottom is the .footer div.

Now here's the issue: .LeftGroup and .RightGroup are overflowing beyond their intended boundaries.

The .MiddleGroup is also not aligned properly where it meets the .LeftGroup div.

I've spent hours attempting to troubleshoot this problem without any success. If someone could assist me, that would be greatly appreciated!

The actual site code isn't too complex; I've provided an explanation within the style sheet. Here's the CSS (style) code:

 .BodyBackground      {
               background-image: url ('../Pictures/Background.jpg');
           background-repeat: no-repeat;
           padding-top: 1%;
           padding-bottom: 1%;
           padding-left: 17%;
           padding-right: 17%;
           position: fixed;
           top: 0;
           left: 0;
           right: 0;
           bottom: 0;
           -webkit-background-size: cover;
           -moz-background-size: cover;
           background-size: cover;
           background-position:center center;
           z-index: 0;
           overflow: auto;
           height: 100%;                                           }

  .AllContent      {
               background-image: url('../Pictures/BackgroundFour.png'); 
           background-repeat: no-repeat;
           position: center;
           -webkit-background-size: cover;
           -moz-background-size: cover;
           background-size: cover;
           background-position:center center;
           box-sizing: border-box;
           width: auto;
           height: auto;
           padding: 20px;
           border-style: solid;
               border-color: orange;
           }

   .headerOne      {
        background-image: url('../Pictures/Background.jpg');
           box-sizing: border-box;
           width: 100%;
           padding: 10px;
           height: 200px;
           box-shadow: 5px 5px 5px #333333;
           }

 .headerTwo        {                        
           font-family: Verdana, Arial, sans-serif; 
           box-sizing: border-box;
           width: 375px;
           height: 70px;
           padding: 0px;
           overflow: hidden;
           white-space: nowrap;     
           text-indent: 3%;
           font-weight: bold;
           font-size: 18px;
           color: white;
           margin-bottom: 1%;
           position: relative;
           top: 37%;
           }


 .navOne               {
           box-sizing: border-box;
           width: 100%;
           padding: 2px;
           height: 20px;
           box-shadow: 3px 3px 3px #333333;
           margin-top: 1%;
           margin-bottom: 3%;
           position: relative;
           top: 35%;
           font-size: 12px;
           font-family: Verdana, Arial, sans-serif; 
           font-weight: bold;
           text-indent: 6%;                 
           background-color: #3D75D5;
           overflow: hidden;
           white-space: nowrap;
           }

  a:hover          {
           color: Brown;
           }    

  nav a        {
           color: white;
           }    



  .LeftGroup       {
           box-sizing: border-box;
           background-color: white;
           width: 20%;
           padding: 10px;
           height: auto;
           margin-top: 1%;
           position: relative;
           float: left;
           }

  .RightGroup      }
                   box-sizing: border-box;
           background-color: white;
           width: 20%;
           padding: 10px;
           height: auto;
           margin-top: 1%;
           position: relative;
           float: right;
           }

  .MiddleGroup     {
           box-sizing: border-box;
           background-color: lightblue;
           margin-top: 1%;
           width: 60%;
           padding: 10px;
           height: auto;
           position: relative;
           left:20%;
               float: center;
               }                        

  .Footer          {
           box-sizing: border-box;
           background-color: gray;
           margin-top: 0;
           width: auto;
           bottom: 0;
           padding: 5px;
           position: relative;
           text-align: center;
           color: white;

                    }                       

Answer №1

  • It appears that in the line - .RightGroup }, you mistakenly added a closing brace instead of an opening brace {.
  • Please remove the position: relative; left:20%; from .MiddleGroup and replace it with float: left;. Also, eliminate float: center; as there is no such value for float.
  • Lastly, include overflow: hidden; to .AllContent
  • .BodyBackground and .AllContent do not require the position: style. You can remove them. Additionally, position: center; is incorrect.

Answer №2

To align your content using Bootstrap's grid system, simply download Bootstrap from this link and implement the following code snippet:

<div class="row"> 
<div class="col-md-4>
. This will allow you to specify column widths within your rows with ease.

Bootstrap's grid system offers a total of 12 columns on a webpage, where you can divide them into sections such as 4, 4, 4, 8, 4, and so forth. Leveraging Bootstrap is highly recommended for efficient layout design.

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

Master the art of creating click events using only CSS

Is it possible to achieve this example using only CSS? If not, what would be the alternative solution? Any JSFiddle examples would be greatly appreciated! How can I also add slashes - should I use an image or can it be done with CSS? And what about the t ...

Discovering JSON data embedded within a script tag in an HTML response using Jsoup

Looking for help with extracting JSON content from script tags embedded in an HTML file. I attempted to use Jsoup without success. Can anyone provide guidance on utilizing JSOUP or another library for this task? Thank you in advance. ...

Steps to alter background image and adjust its height upon function activation

I am working on a search page with an advanced search option that only certain users can access. I need the height of my div to increase accordingly and also change the background image to a larger size when the advanced search is selected. How can I make ...

"Initial loading issue with bootstrap carousel causes slides not to slide smoothly

I am currently working on implementing a slider carousel using Bootstrap. Although the 'active' image loads successfully, the controls and slide functionality are not working as expected. Initially, I believed this exercise would be straightforwa ...

Using a single datalist in HTML5 to define options for multiple input elements

When working with HTML5, I discovered that you can create multiple input elements that share the same option list like this: <datalist id="list1"> <option value="A"> <option value="B"> </datalist> input1: <input list="l ...

Can a border-bottom be made the same size as a class it is not linked to in CSS?

Can I set a border-bottom to match the size of a separate class? For example, I want a border-bottom at the bottom of each <section> tag. However, since the sections span the full width of the screen, the border-bottom inherits that width. Each < ...

Step horizontally to scroll varying amounts

On my webpage, I have implemented two buttons to scroll left and right. When these buttons are clicked, the page should move left or right by the width of each individual div (since they all have different widths). I am unsure if this functionality can b ...

Update the link by simply clicking on a div tag

I am currently working on a PHP page and my goal is to add the extension ?id=variable_value to its URL when I click on a specific div. However, whenever I try to do this, it shows me an error message stating that the URL with the extension is undefined. B ...

Troubleshooting Tips: Removing a Specific Line from a Canvas Using Javascript

I need to find a method for removing a specific line without having to clear and redraw it. Learn more about clearing specific lines in Canvas with HTML5 I came across this question where everyone suggested clearing the entire page and redrawing it. Is t ...

Applying CSS text-shadow to an input field can cause the shadow to be truncated

I've encountered an issue when applying text-shadow to an input field, where the shadow appears to clip around the text. Here is the CSS code I used: @import url('https://fonts.googleapis.com/css2?family=Jost:ital,wght@0,100..900;1,100..900& ...

Drag and drop surprise: When items are dragged onto the screen, a magical box will appear. But watch as the box disappears when the item is dragged

I am a newcomer to knockout JavaScript and am currently utilizing Knockout drag and drop functionality in my project. Initially, I have two divisions - one is visible while the other has a display property set to none. During the drag enter function, I wan ...

Changing images based on different triggers - HTML Markup with jQuery Carousel

I have a website where I'm using a plugin called CarouFredSel, available at Most of the time, it works perfectly fine. However, there are some images that cause the markup to break. I've tried troubleshooting the issue but haven't been able ...

Retrieving a unique custom data-attribute using select2 on a <select> element

If you were presented with the following HTML5 snippet: <select id="example"> <option value="AA" data-id="143">AA</option> <option value="BB" data-id="344">BB</option> </select> $("#example").select2(); What i ...

The page is not loading correctly until a refresh is done

My website seems to be displaying incorrectly on most browsers until the page is refreshed. Check it out here: I'm puzzled as to why this issue is occurring and why it resolves itself upon refresh (even without clearing the cache). The layout consis ...

The fillOpacity and opacity properties appear to be malfunctioning

Note: While I understand that image masking can solve my issue, I prefer not to use it as it would require me to use my image as a background and could present accessibility challenges. I am specifically looking for solutions involving clip-path. Issue: T ...

Can you tell me the specific name of the HTML document style that features two columns?

Here are two websites that showcase a unique two-column style layout: http://momentjs.com/docs/ I find these sites visually appealing and I am curious about the specific name of this style. Is there a template or tool available to create documents with a ...

Looking for a smart way to extract all the selected elements from a form?

I am attempting to retrieve all the checked items from this form using JavaScript. I have looked at previous solutions, but none of them fit my requirements. <form id="checkform" class="container" style="margin-top:20px;"> <input type="checkb ...

Conceal the input field prior to making a selection from the dropdown menu

I have implemented a drop-down menu for selecting dependencies, similar to how it functions in JSFiddle. $('#user_time_zone').on('change', function() { dateCalender = $(this).val(); if (dateCalender == 'Single Date') { ...

Maximizing the functionality of PHP switch to create clickable list items

I have successfully created a simple switch for my website, but I am encountering an issue with clickable list items. The concept is that when I click on any of the list items, the switch should display the appropriate greeting (whether it's Night or ...

Creating a JavaScript array in Rails 4 based on current data without the need to reload the webpage

Currently in my rails 4 app, I am working on a unique tags validation using jquery validate to ensure that tags are not duplicated before they can be added to an item. The tag list structure is as follows: <div id="taglist"> <span class="label ...