Reputation: 21
I try to make the popup container like this example
But it show like this wrong layer or something
Here is my code:
HTML:
<div class="popup-container arrow-top ">
CSS:
.popup-container {
display: none;
padding: 20px 10px 0 0;
position: absolute;
margin: 0 auto;
z-index: 999;
top: 100%;
right: 50%;
border-radius: 10px 0px 10px 10px;
background-color: #FFFFFF;
box-shadow: rgb(170, 170, 170, 0.6) 0 1px 14px
}
.popup-container:before {
content: "";
width: 20px;
height: 20px;
transform: rotate(90deg) skewX(45deg) scaleY(cos(45deg));
box-shadow: 0 1px 14px rgba(0,0,0,.2);
background-color: #FFFFFF;
position: absolute ;
z-index: 999;
}
.popup-co`ntainer.arrow-top:before {
right: -3px;
top: -4px;
}
Upvotes: 2
Views: 70
Reputation: 647
I believe this is what you're trying to achieve, you're code was good, but you needed to adjust some values in order for your popup to show up right.
function showPopup(elem){
let style = elem.querySelector(".popup-container").classList.toggle("show-popup");
}
body{
background: whitesmoke;
}
.text-with-popup{
display: inline-block;
position: relative;
cursor: pointer;
user-select:none;
}
.show-popup{
display: block!important;
}
.popup-container {
display: none;
padding: 20px 10px 0 0;
position: absolute;
margin: 0 auto;
z-index: 999;
top: calc(100% + 16px);
right: 0;
width: 100px;
height: 100px;
border-radius: 10px 0px 10px 10px;
background-color: #FFF;
box-shadow: rgb(170, 170, 170, 0.6) 0 1px 14px
}
.popup-container:before {
content: "";
width: 20px;
height: 20px;
transform: rotate(90deg) skewX(45deg) scaleY(cos(45deg));
background-color: #FFF;
position: absolute ;
z-index: 999;
}
.popup-container.arrow-top:before {
right: -3px;
top: -4px;
}
<div class="text-with-popup" onclick="showPopup(this)">
Click here to toggle popup display
<div class="popup-container arrow-top ">
<div>
Upvotes: 0