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

Is there a way to make the hoverzoom effect only apply to a specific object instead of all objects?

I'm currently troubleshooting my code in order to implement a hover effect on Mui <cards> when a user hovers over the object. I have managed to make it work partially, but the issue is that the effect gets applied to all objects instead of just ...

Tips for aligning elements of varying heights

Currently, I am tackling a responsive web design challenge involving floating multiple items in 4 columns side by side. The issue arises due to the varying heights of these items, causing the floating to behave improperly. Here is the current problem illu ...

Managing elements within another element in Angular

I am currently exploring the use of Component Based Architecture (CBA) within Angular. Here is the situation I am dealing with: I have implemented three components each with unique selectors. Now, in a 4th component, I am attempting to import these compon ...

Managing both clicking and hovering events on a single element, ensuring that the popup modal remains open as long as it is being hovered over

After successfully implementing click and hover functionality on an element, I was able to position the popup relative to the mouse pointer based on a previous solution. However, I am now facing an issue where I want the popup modal to be fixed in a specif ...

How can I showcase Bootstrap cards horizontally within a razor foreach iteration?

I seem to be experiencing a mental block on how to arrange bootstrap cards in a horizontal layout using a for each loop. By default, they appear vertically. Below is my razor code: @foreach (var item in Model) { var imgUrl = Url.Content("~/Conte ...

Issues with Bootstrap Toggle Button functionality

I encountered a navbar error while working on my Django Project. After adding a few script tags, the navbar started to move down but did not return back to its original position. It worked fine before. By commenting out some script tags, it began to work a ...

Utilizing CSS nested spans and setting custom width attributes

I'm curious about how nested spans and CSS handle the width attribute. In the HTML code provided, the 'wide' class sets the width while the 'box' class adds a border. I've noticed that the width is only applied when both class ...

Tips on utilizing jquery slideDown alongside appendTo

I am currently utilizing an ajax request to retrieve records from the database and then appending the data in HTML. However, I want the HTML to slide down once the data has been appended, but I'm unsure of how to achieve this. Below is the ajax metho ...

Strange height problem detected in embedded YouTube video

Currently, I have a page with an embedded YouTube video that is intended to be placed in a container with a variable width. When the video is outside of the container, the aspect ratio appears normal. However, once it is placed inside the container, the he ...

Is there a method to incorporate a scroll event into the ng-multi-selectdropdown, a npm package?

Query: I need to incorporate a scroll event in the given html code that triggers when the div is scrolled. However, I am facing issues with implementing a scroll event that works when the elements are being scrolled. <ng-mult ...

A table featuring an HTML select element that allows users to choose from preset options or manually enter

My goal is to incorporate a select box where users can either choose from a set list of options or input their own custom value. The select element is nested within a table. Unfortunately, using datalist is not a viable solution for me in this case. I have ...

Trick to keep horizontal element alignment intact when scroll bar appears

Currently, all my pages are designed with the standard fixed-width-margin-left-right-auto layout. .container{ width:900px; margin:0 auto; } An issue arises when some of these pages exceed the height of the window, requiring a vertical scroll ba ...

The footer is supposed to be at the bottom, but unfortunately, the clear float isn

Today seems to be a rough one without enough coffee, as I'm struggling to remember how to do this I am trying to achieve the following layout: header content float float footer The content section contains two floating elements. The problem is ...

Utilizing Angular 2 for dynamic CSS binding: manipulating style.width and style.height properties

I am experiencing some unusual rendering issues when using plain HTML5 canvas and CSS binding with A2. Can anyone please explain the difference between the following code snippets: <canvas height="400" width="1200" #background> </canvas> AND ...

Disappear text gradually while scrolling horizontally

There is a need to create a special block that displays fading text on horizontal scroll. However, the problem is that the block is situated on a non-uniform background, making the usual solution of adding a linear gradient on the sides unsuitable. Click ...

What is the best way to position an <a> tag in the top right corner of a card using Bootstrap?

I own a card that features an image in the background. <div class="col-12 col-sm-8 col-md-6 col-lg-4 mt-4"> <div class="card"> <img class="card-img" style=" filter: brightness(75%);" src=& ...

Vanilla JavaScript - Conceal all remaining div elements

I have a situation where multiple divs are only visible after clicking a link. How can I ensure that when one div is clicked, all others are closed so that only the clicked one remains visible? Currently, I am using the following JavaScript: functio ...

The JavaScript function for clearing an asp.net textbox is not functioning properly

I am working on an ASP.net project and have encountered an issue with two textboxes. When one textbox is clicked on, I want the other one to clear. Below is the code I have for the textboxes: <asp:TextBox runat="server" ID="box1" onfocus="clearBox2()" ...

The Django static files were uncooperative and refused to function

I've encountered an issue with my HTML files while using Django. Some files work perfectly fine when I load static files, but others don't seem to cooperate. I'm perplexed as to why this inconsistency exists! Have I overlooked something impo ...

Global variable appears undefined in Angular 2 view, yet it is still displaying

I'm running into issues with my Angular 2 code. Inside my ts file, I have the following: import { Test } from '../../../../models/test'; import { TestService } from '../../../../services/test.service'; import { Job} fr ...