How can I adjust my css to have the child div (popup like menu) right align to the parent div which is a button in this case?
Right now i have this
and im trying to make it look like this....
https://jsfiddle.net/JokerMartini/pqw2jeb9/
body {
padding: 20px;
font-family: Helvetica;
}
.wrapper {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 10px;
}
.box {
background-color: #20262e;
color: #fff;
border-radius: 3px;
padding: 20px;
font-size: 14px;
overflow: hidden;
}
.menuRoot {
display: inline-block;
}
.overlay {
background: rgba(0, 0, 0, 0.25);
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
}
.popup {
position: absolute;
z-index: 90;
background: blue;
border-radius: 4px;
padding: 12px;
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.75);
}
<div >
<div >A</div>
<div >B</div>
<div >
Hi
<div role="menu" >
<div>
<!-- Activator -->
<div>
<button type="button" >Paret Button</button>
</div>
<!-- Overlay -->
<div ></div>
<!-- Popup -->
<div >
<button type="button" >Child Button</button>
</div>
</div>
</div>
Great
</div>
<div >D</div>
</div>
CodePudding user response:
I tried a lot, I remembered I'm Arabic and I did this too much, my lovely language starts from right to left so just add dir="rtl" to menu root
body {
padding: 20px;
font-family: Helvetica;
}
.wrapper {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 10px;
}
.box {
background-color: #20262e;
color: #fff;
border-radius: 3px;
padding: 20px;
font-size: 14px;
overflow: hidden;
}
.menuRoot {
display: inline-block;
}
.overlay {
background: rgba(0, 0, 0, 0.25);
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
}
.popup {
position: absolute;
z-index: 90;
background: blue;
border-radius: 4px;
padding: 12px;
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.75);
}
<div >
<div >A</div>
<div >B</div>
<div >
Hi
<div role="menu" dir="rtl">
<div>
<!-- Activator -->
<div>
<button type="button" >Paret Button</button>
</div>
<!-- Overlay -->
<div ></div>
<!-- Popup -->
<div >
<button type="button" >Child Button</button>
</div>
</div>
</div>
Great
</div>
<div >D</div>
</div>
CodePudding user response:
You can use margin-left: -20px; on your .popup class.
Result:


