The offspring surpasses the parent's limits and extends beyond its

I am designing a webpage layout that includes 2 navigation bars (top), a top-graphic (middle) flexbox, and a content flexbox (bottom).

Within the top-graphic flexbox, I want to add a black box for text. However, I am facing issues with the box overflowing beyond the boundaries of its parent element, extending into the content flexbox when the page is resized. I need the box to remain within the confines of its parent element and adjust its size according to the parent, preventing overlap with the content flexbox upon resizing.

.nav {
  display: flex;
  flex: 1;
  background-color: white;
  flex-direction: column;
}
.topnav {
  flex: 1;
  background-color: white;
  border-bottom: ridge 1px;
}
.bottomnav {
  flex: 1;
  background-color: white;
}
.topgraphic {
  overflow: hidden;
  position: relative;
  flex: 2;
  background-color: lightblue;
  z-index: -2;
}
.topgraphic img {
  background-size: cover;
  background-repeat: no-repeat;
  position: absolute;
  width: 100%;
  height: 100%;
  -moz-box-shadow: inset 0px 12px 15px -12px #696868;
  -webkit-box-shadow: inset 0px 12px 15px -12px #696868;
  box-shadow: inset 0px 12px 15px -12px #696868;
  z-index: -1;
}
.topgraphic .textbox {
  box-sizing: inherit;
  position: absolute;
  margin-right: 5%;
  margin-bottom: 10%;
  width: 30%;
  height: 80%;
  background-color: rgba(0, 0, 0, 0.6);
}
.content {
  z-index: -5;
  flex: 7;
  background-color: white;
  min-height: 25%;
}
<div class="nav">
    <div class="topnav"></div>
    <div class="bottomnav"></div>
</div>
<div class="topgraphic">
    <img alt="TopGraphic" class="auto-style1" src="Images/Topgraphic.jpg" />
    <asp:Image ID="Image1" runat="server" />
    <div class="textbox">
        <!-- <div class="topText">
        <h1>Demonstration</h1>
        </div> -->
    </div>
</div>

Answer №1

Trying to decipher what exactly you're searching for can be a bit challenging, so I've taken a shot at it based on the code you've provided.

Does this layout resemble what you have in mind?

* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: gray;
  padding: 1%;
}
.outer {
  display: flex;
  flex-flow: column;
  height: 98%;
  width: 90%;
  margin: 0 auto;
  box-shadow: 0px 0px 10px 0px #696868;
}
.top { 
  display: flex;
  flex-flow: column;
  background-color: white;
}
.middle { 
  background-color: lightblue;
  background-image: url(http://lorempixel.com/400/100/sports/9/);
  background-size: cover;
  background-repeat: no-repeat;
  clear: right;
}
  .middle .textbox {
     float: right;
     width: 30%;
     height: 70px;
     background-color: rgba(0,0,0,0.7);
  }
.content {
  position: relative;
  flex: 1 0 auto;
  height: 0;
}
.content-inner {
  background-color: white;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
}
<div class="outer">
  <div class="top">
    <div class="top">top top</div>
    <div class="bottom">top bottom</div>
  </div>
  <div class="middle">
      <div class="textbox">
          text box
      </div>
    </div>
  <div class="content">
    <div class="content-inner">content</div>
  </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

Tips for containing `overflow` within a flexbox container

I've organized my body space into three sections: header, content, and footer. To achieve a sticky footer effect at the bottom, I used the flex property in my layout. However, I'm struggling to add a scrollbar to my main container box. I've ...

Methods for verifying if a file is included in another file, while disregarding any whitespace adjustments

Let's say I have multiple CSS files (a.css, b.css, ..., e.css) and after concatenating and compressing them, I get a new file called compressed.css. Now, I need to verify if each of the original CSS files is included in the compressed.css file. Are th ...

How can one transfer information from a client to a server and complete a form using JavaScript?

Can the information be transferred from a client to the server using just JS, then fill out a form on the server, and finally redirect the client to view a pre-filled form? I am considering utilizing AJAX to send a JSON object, but unsure if it will be s ...

Tips for sending two values to a PHP file using JavaScript Ajax

I have created a code for two dropdown menus. The goal is to select values from both menus and send them to a php file using the GET method. The values should be sent to the php file only when both menus have selections made. Below is the code snippet: ...

The div is not displaying the conditional styling as expected

I need help with mapping an array of cards wrapped in a div. I want the first, second, second-to-last, and last divs to go on a new line or take up the entire row. My project is in Vue3 and I'm using the PrimeVue component library. <div class=" ...

Automatic page updates triggered by code modifications

I am currently working on a .NET ASPX page where I usually write my classes separately in the app_code folder. However, for this specific page, I needed a temporary class that is only required by this page. So instead of creating a separate file, I decid ...

Implementing a feature that ensures html elements are transparent in a PDF conversion

I am in the process of converting a webpage into a format that is easily printable as a PDF, while ensuring that it maintains the same appearance. Many tools for printing to PDF do not support background images or colors, so I am attempting to overcome thi ...

Why is the video background not taking up the entire width of the div element?

I've recently integrated the jquery.videoBG plugin into my project to add a video background. Here's the HTML code: <div id="div_demo"> <div class="videoBG"> <video autoplay="" src="media/snow.mp4" style="position: abso ...

Ensure that all items are centered while positioning one in the corner

Lately, I've been diving into the world of flexbox and trying out new things. However, there are still some concepts that elude me. My current project involves creating a straightforward layout with three flex items (children). The container is confi ...

Tips for identifying modifications in an input text field and activating the save button

Currently, I am developing a function that can detect any changes made in the text field and then activate the save button accordingly. This code is being executed in Visual Studio 2017, using HTML and JavaScript. (function () { var customer_addres ...

Learn how to use Javascript and ASP.NET to refresh the parent page in Mozilla Firefox browser

The code window.opener.location.reload(); works well in Internet Explorer, but it doesn't refresh the parent page in Mozilla Firefox. Can someone please advise me on how to refresh the parent page in a way that is cross-browser compatible? Here is th ...

Expanding the outer div with Jquery's append() function to accommodate the inner div elements perfectly

I am facing an issue where my outer div does not expand automatically to fit the elements I append inside it using jQuery. The structure of my div is as follows: <div class="well" id='expand'> <div class="container"> < ...

Deselect an HTML checkbox using a corresponding label's "for" attribute

Below is the html code I am using to display a checkbox with an image: <div class="testClass"> <input id="111" name="compare_checkbox" type="checkbox" /> <label for="111"> <i class="icon" aria-hidden="true"&g ...

JavaScript effectively divides multiple child dropdowns with the main dropdown, thanks to Bootstrap innovation

I have implemented a jQuery function to dynamically change multiple child dropdowns based on the selected value of the main dropdown. For reference, you can view the image here. However, I encountered an issue when applying the Bootstrap styles "form-con ...

Managing HTML5 Video in a slider

I've designed a unique video slider that cycles through 4 videos. Each video has a custom play button and additional overlay content. Once the video starts playing, the overlay content and play button fade out to reveal the default video controls. The ...

What is the best way to switch between components when clicking on them? (The component displayed should update to the most recently clicked one

I am facing a challenge in rendering different components based on the navbar text that is clicked. Each onclick event should trigger the display of a specific component, replacing the current one. I have 5 elements with onclick events and would like to re ...

Canvas - Drawing restricted to new tiles when hovered over, not the entire canvas

Imagine having a canvas divided into a 15x10 32-pixel checkerboard grid. This setup looks like: var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); var tileSize = 32; var xCoord var yCoord ...

React isn't updating the on-change value despite changes being made

In my React application, there is a file called EditTodos.js that is responsible for updating the to-do list. When I click on the "Edit" button, it triggers a pop-up modal component. import React, { useState } from "react"; import { Button, Modal } from " ...

Transitioning images smoothly and responsively with jQuery, creating a beautiful

Hey there! I'm looking for some help with transforming this jQuery effect. Instead of having fixed sized images, I want to set the size in percentage (width:100%; height:auto) so they can be responsive. Any creative ideas or suggestions? <scri ...

The content div in CSS is causing the menu div to be displaced

I have encountered a difficulty in describing the issue at hand as I am still in the learning phase and consider myself a beginner. Within my container div, there are two other divs - one for the menu and another for the content. Both of these divs float ...