I have a question regarding the proper positioning of one div over another in a specific scenario:
Currently, I am working on creating a toolbar for .col-9.h-100
from my code snippet. My goal is to have this toolbar appear over .col-9.h-100
when clicked by the mouse. Understanding that it's not feasible to assign a child element of .col-9.h-100
with a higher z-index
than its parent, I am working on creating a sibling element with identical dimensions. The idea is for this new element to overlay .col-9.h-100
with a height approximately 20% of .col-9.h-100
.
$('.col-9.h-100').click(function(){
$("\
<div class='row' id='rowToolbar'>\
<div class='col-9 h-100'>\
<div id='toolbar'>\
<button class='btn btn-primary controls'>addNode</button>\
</div>
</div>
</div>
").appendTo($('body'))
})
html,
body {
height: 100%;
}
.row{
margin:0!important;
}
#rowToolbar{
}
.col-9.h-100{
background-color:lightgray;
padding:0;
}
.col-3.h-100{
background-color:lightblue;
}
#toolbar{
background-color:white;
display:inline-block;
width:100%;
height:20%;
}
.controls{
float:right!important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<a class="navbar-brand" href="#">MAIN</a>
<div class="row h-100 w-100">
<div class="col-9 h-100"></div>
<div class="col-3 h-100"></div>
</div>
I've attempted various combinations involving different styles such as display
and z-index
, but none of them have yielded the desired outcome.
Upon running the snippet, you can observe that the toolbox appears appropriately sized but positioned incorrectly. What "game" with z-index
and display
should I employ to arrange them in the correct order?
If possible, could you please demonstrate the correct method for accomplishing this? Thank you in advance.