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

Developing a quiz using jQuery to load and save quiz options

code: http://jsfiddle.net/HB8h9/7/ <div id="tab-2" class="tab-content"> <label for="tfq" title="Enter a true or false question"> Add a Multiple Choice Question </label> <br /> <textarea name ...

Automatically move to the latest message as soon as it is posted

After trying multiple codes and encountering issues, I am attempting to add my message in a textarea that will automatically scroll down. Even though I have my own codes, they don't seem to work properly. I also tried using the code provided Here. ED ...

The navigation bar is missing from the screen

Where is the navbar in this snippet? Did I overlook something important? If so, what? <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <div class="container"> <div class="navbar nav ...

Increase transparency of scrollbar background

Is it possible to adjust the opacity of a scrollbar track? I attempted to use opacity:0.5, but it didn't have any effect. I am using material UI styled, although I don't believe that is causing the issue. const Root = styled('div')(({ ...

Integrating CSS with Material-UI in a React project: A step-by-step guide

I am currently developing a project using React (along with TypeScript) and the Material-UI library. One of my requirements is to implement an animated submit button, while replacing the default one provided by the library. After some research, I came acr ...

Tips for combining a select option and search field into a seamless integrated feature

I'm looking to implement a search field in my project that includes the ability to select specific parameters before running the search. I want it to have a seamless design similar to the image shown below. Although I couldn't find a matching co ...

Trouble with CSS animation when incorporating JavaScript variables from a PHP array

Whenever I use a script to fetch an array of objects from PHP... I successfully display the results on my website by outputting them into Divs. The challenge arises when I introduce CSS animations. The animation only triggers if the variable length excee ...

Elevate Your Designs: A New Perspective on Vertical Alignment

I am struggling to vertically align my text, which spans multiple lines, while implementing the scroll-over effect. I attempted to include vertical-align: middle; in my code, but unfortunately, it did not produce the desired result. Here is my CSS code: ...

Adjust the width of the dropdown menu to match the text input field using jQuery

Struggling with jquery-mobile to collect user information, I am facing an issue aligning the width of my select menu with the text input fields. Despite successfully matching the background and border colors of the select menu with the text input fields, ...

Steps for transferring data between two components

I'm looking for a way to transfer an object's id from one component to another. <ng-container matColumnDef="actions"> <mat-header-cell *matHeaderCellDef></mat-header-cell> <mat-cell *matCellDef="let user"> ...

Display a floating label above the text input when it is focused or when it holds text

I am trying to create an animated search bar where the label moves from being over the text input to above it. I came across a helpful example in a fireship.io video, which includes the CSS and HTML code available here The example I found demonstrates the ...

Is it possible to leverage React/Next.js for dynamically adding HTML content based on element IDs when integrating with Netlify forms?

Sorry if this question has already been addressed somewhere. I've spent hours searching and troubleshooting without success. I'm still in the process of learning React, as it's a new concept to me. I just need to implement it for a contact ...

Tips to enhance web page loading speed when parsing JSON data from a URL

While extracting data from a JSON file accessed via URL, I am experiencing long loading times. Surprisingly, the website manages to display the same data only when it's ready, and I aspire to achieve a similar functionality. I have yet to discover a ...

Using asynchronous data in Angular 2 animations

Currently, I have developed a component that fetches a dataset of skills from my database. Each skill in the dataset contains a title and a percentage value. My objective is to set the initial width value of each div to 0% and then dynamically adjust it t ...

The CSS div mysteriously vanishes right before I can trigger the click event

My CSS code looks like this: #searchbar-wrapper input#header-searchbar:focus + #search-dropdown-wrapper { display: block; } The purpose of this code is to make a dropdown visible when a user focuses on a textbox. The default behavior should be th ...

Ensure that the input box expands to occupy the entire HTML page

After reviewing numerous pages and questions related to this topic, I have located the correct solution but am struggling to implement it. My goal is to achieve a similar outcome to the second question, but I'm having difficulty figuring out how to do ...

CSS Image Placement

If I have an image with a width of 2000px, where the snazzy design aspect is located about 600px in and spans about 900px. My goal is to use this image as the background for a website, ensuring that the snazzy design remains centered even when stretching t ...

Is there a way to click on a button and have its background color change randomly each time?

I am facing an issue with a button on my HTML page. When the button is clicked, I want its background color to change to a random different color. However, despite trying various sources, I am unable to get it right. It seems like I am not placing the code ...

Placing the navigation bar on the right side of the section

.middle-site-content-container { width: auto; height: auto; border: 2px red solid; display: flex; /*Le pot pozitiona in line*/ flex-wrap: wrap; justify-content: center; flex-direction: row; margin: auto; } .middle-site-content-1, .middle ...

Using an HTML ellipsis without setting a specific width

I am working on achieving a specific layout as shown in the screenshot below. If both SPAN and B fit within the box, they should be displayed one after another. If they do not fit, SPAN should have an ellipsis while B is fully displayed (never larger tha ...