I have been trying to add two divs on top of each other without using Position:absolute, and it is not working.
Does anyone know how to do that?? Thank you.
<div class="row" style="background-color:aqua;">
<div class="col-xs-12 col-sm-12 col-md-12" >
<div style="left:0px;">
<asp:Label ID="lblEmail" runat="server" Text="Label" />
</div>
<div style="left:0px;">
<asp:Button ID="btnJoin" runat="server" Text="a button"
CssClass="btn btn-lg btn-primary"/>
</div>
</div>
</div>
By setting this element to grid-column-start to 2, we are assigning this div to one of the same columns as the first element, allowing the overlapping effect to take place without using absolute.
You can use the CSS position property in combination with the z-index property to overlay an individual div over another div element. The z-index property determines the stacking order for positioned elements (i.e. elements whose position value is one of absolute , fixed , or relative ).
Fixed. The fixed value is similar to absolute as it can help you position an element anywhere relative to the document, however this value is unaffected by scrolling.
By using a div with style z-index:1; and position: absolute; you can overlay your div on any other div . z-index determines the order in which divs 'stack'. A div with a higher z-index will appear in front of a div with a lower z-index . Note that this property only works with positioned elements.
you can do this using grid.
.parent {
display: grid;
grid-template-columns: 1fr;
}
.parent div {
padding: 50px;
background-color: rgba(0,0,0,0.5);
grid-row-start: 1;
grid-column-start: 1;
}
<div class="parent">
<div class="child1">
1
</div>
<div class="child2">
2
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With