Overlap of one div with another in Bootstrap

Welcome to the world of web development and bootstrap! I'm currently working on making my page responsive, but running into issues with divs overlapping when the browser is resized.

As you can see, the top div is labeled "main-content" and the bottom white div is labeled "content". The top 3 pictures (top-hive) and the bottom 2 pictures (bottom-hive) are each contained within separate divs. However, when the page is zoomed out, these pictures extend beyond their respective divs.

I would greatly appreciate it if someone could provide guidance or suggestions on how to address this issue.

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>S.H.I.E.L.D</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom -->
    <link rel="stylesheet" type="text/css" href="css/main.css">

  </head>
  <body>

    <div class="nav container">
    </div>

    <div class="main-content container">
        <div class="top-hive row">
            <img src="images/hive1.png">
            <img src="images/hive2.png">
            <img src="images/hive3.png">
        </div>

        <div class="bottom-hive row">
            <img src="images/hive4.png">
            <img src="images/hive5.png">
        </div>

    </div>

    <div class="content container">

    </div>

    <div class="footer container">
        <h5>Copyright (2015)</h5>
    </div>





    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

CSS

body {
    background: url(../images/BG_01.png) repeat fixed top center;
    background-size: 100% auto;
}
/*NAV*/
.nav {
    background: url(../images/header_01.png);
    background-position: center;
    height: 417px;
    width: 100%;
    position: relative;
    z-index:2;
}
/*MAIN CONTENT*/
.main-content {
    background: url(../images/CBG_03.png) no-repeat;
    height: 684px;
    background-position: center;
    max-width: 100%;
    text-align: center;
    margin-top: -215px;
    position: relative;
    z-index:1;
}
.top-hive {
    margin-top: 106px;
}
.top-hive img {
    padding: 5px;
}
.bottom-hive {
    margin-top: -60px;
}
.bottom-hive img {
    padding: 5px;
}

/*CONTENT*/
.content {
    background: url(../images/CBG2_03.png) no-repeat;
    height: 621px;
    background-position: center;
    width: 100%;
    text-align: center;
    margin-top: -12px;
}
.text h3 {
    text-transform: uppercase;
    font-size: 2.1em;
}
.text p {
    font-size: 1em;
}
.footer {
    background: #050719 url(../images/footer_02.png)repeat;
    height: 178px;
    width: 100%;
    text-align: center;
    background-position: center;
}

/*FOOTER*/
.footer h5 {
    color: #58a7d9;
    margin-top: 127px;
}

Answer №1

Due to the smaller browser width, one of the hexagons is being pushed down, making the entire structure three hexagons high rather than two.

To prevent this issue, consider setting a min-height on the .main-content div to allow it to adjust to the new hexagon arrangement:

.main-content {
    background: url(../images/CBG_03.png) no-repeat;
    min-height: 684px; // min-height
    background-position: center;
    max-width: 100%;
    text-align: center;
    margin-top: -215px;
    position: relative;
    z-index:1;
}

If you require a consistent height across all screens, utilize media queries for smaller devices and adjust the hexagon size accordingly to avoid wrapping onto a new line.

*edit: For more convenient editing and testing, consider sharing the code on jsfiddle or codepen rather than an imgur link.

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

Selenium in Python does not have the capability to extract innertext

I am attempting to extract the text from a specific webpage's title. The HTML tag I need to target is as follows: <h1 class="d2l-page-title d2l-heading vui-heading-1 bsi-set-solid">TEXT HERE</h1> I have confirmed that my XPATH is accurat ...

I'm having trouble retrieving and rendering data in HTML using AngularJS and Spring

After fetching the data, I am unable to see it in the HTML code. The web browser console displays the JSON data but it is not visible in the HTML code. Here is my AngularJS code: $scope.refresh = function(){ fetchData(); }; $scope.fetchData = functio ...

Issues encountered when selecting table data for filtering

One issue I am facing is with my HTML table that contains a lot of data. I have created a select option to filter the table and display the filtered data. The select options are based on the "route" column, with only three options available: Marikina, Mont ...

Adjust the width of HTML to accommodate the entire video while also specifying a custom height

After researching extensively on this solution, I am still unable to resolve the issue. My goal is to display a video with full width and a custom height of width='100%' height='100px'. <div class="row"> <div class="video- ...

Material Design - Adjustable Sidebar

Looking for advice on creating a reactive Appbar and Drawer. Can anyone provide guidance or examples? The goal is to have the drawer dynamically undock and hide when the browser is small, and dock the drawer when larger. Ideally, this would work similar t ...

Sending a parameter to an attribute

Enlightened. Fresh post with a comprehensive backstory for understanding the objective. A game concept is in progress where participants select two characters for a duel. Each 'character' is considered an object, initially assigned a boolean pro ...

What is the best way to access the width of the top-level parent div and adjust the widths of its child and parent divs according

I'm currently working on creating a custom directive in Angular 4 to enable resizing of a div. Here's the HTML code snippet: <div class="super-parent"> <div class="parent"> My Div content <div class="child" re ...

Display an additional div when the mouse hovers over the image

I'm currently working on a "cast" section for one of my projects, and I'd like the actor's character to be revealed when the actor is hovered over. How can I make this happen without leaving a gap on the page when hiding the display of the d ...

Establish a timeout period for ajax requests using jQuery

$.ajax({ url: "test.html", error: function(){ //do something }, success: function(){ //do something } }); At times, the success function performs well, but sometimes it does not. How can I add a timeout to this ajax re ...

Tips for utilizing the value retrieved from foreach within ng-repeat using angularjs

In order to display the field "seconddate" only if it is greater than "firstdate", a function needs to be implemented that will return true or false based on the comparison. The date format is in dd mmm yyyy (e.g., 22 Nov 2017). However, it is unclear how ...

Notification of Exceeding File Size Limit

Seeking assistance with implementing a 'filesize' error message into a script used for uploading BLOB files to a mySQL server. if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($dat ...

Is it possible to utilize a variable while assigning an element id through a JavaScript function?

Currently, I am in the process of learning JavaScript and have come across a scenario that has left me uncertain. I am attempting to utilize a variable in a particular situation and am unsure if it will work as expected. I am looking to assign a unique id ...

"Utilize AJAX to submit the value of the text box input from a jQuery slider when the Submit Button

Whenever I adjust the sliders, the value is shown in an input textbox. However, when I move the slider and check the values echoed from the textboxes on another PHP page, they are always displaying as 0. Even after clicking the submit button, it still echo ...

Is it possible to have several responsive images layered on top of one main responsive image

I'm currently working on a map project that involves multiple map pointers (7). By using the code below, I have successfully positioned them correctly: <div style="position:relative; left: 0; top: 0;"> <img src="images/JCCareas.png" cla ...

Ways to assign dynamic widths to inner divs within a parent div automatically

I am working with divs <div id='top' > <div id='top-border' > </div> <div id='top-menu' > <jdoc:include type="modules" name="top-menu" style="well" /></div> </div> and adjust ...

Attach an object securely to a specific spot

I'm facing an issue with my product cards where the text mentioning "free shipping" is not aligned properly when there are no ratings. How can I ensure that all free shipping texts are positioned consistently on the card? Should I modify the position ...

Looking for a straightforward way to incorporate a "Read more" and "Show Less" functionality into a Wordpress site using Javascript?

As a last resort, I am seeking a quick and simple fix. I have been experimenting with Javascript to implement a 'Read more...' & '... Read Less' feature on six different sections of a single page. The goal is to display only the fi ...

Logging client side errors to the server with AngularJS exclusively

Hey there, I'm a beginner in angularjs and I am trying to figure out how to create a client-side error/exception logger (.log/.js) file that sends data to the server using only angularjs. I prefer not to use jquery for this particular task. Any assis ...

Utilize the power of Angular 12 and Bootstrap 5 with the ability to load multiple imported scss theme files

I'm currently incorporating Angular 12 and Bootstrap 5 into my project. For loading Bootstrap, I have imported it from my SCSS file along with three theme SCSS files. This is how it appears: style.scss: @import './assets/styles/theme1.scss&apo ...

Executing a python script from an html page by providing it with a string input

I've been searching everywhere for a solution to this problem, but I've only been able to find information on either the python side or the javascript side, and I really need both. Currently, I have a python script that I execute in the command ...