I have a body consisting of 2 navigation bars(top), top-graphic(middle) flexbox and a content flexbox(bottom).
Within the top-graphic flexbox I want to insert a black box in which I can put text. When I make this box, it doesnt overflow the top of the parent box, however it overflows the bottom and the right side of the parent, continueing into my content box when I resize the page. I want my box to stay inside the boundaries of its parent element and take my parent into respect when I set my width/height, so that it doesnt overlap the content flexbox when I resize the website.
.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>