I have multiple blocks in a row, each block have custom popover div. If the user hovers on last div or second last div in a row then popover is going beyond the window width. I want, if there is no space on the right side for popover, then tile-box class change to tile-box1. Thanks in advance! Below is the code pen URL for the reference and i am also attaching the image.
.content {
display: flex;
flex-wrap: wrap;
}
.box {
width: 150px;
height: 100px;
position: relative;
border: 1px solid #ddd;
}
.box:hover .tile-box {
display: block;
;
}
.tile-box {
display: none;
position: absolute !important;
z-index: 9;
top: -6px;
left: 169px;
width: 220px;
height: auto;
/* padding: 15px; */
margin-top: 15px;
position: relative;
background: #fff;
border-radius: 8px;
box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.06);
border: solid 1px #e8e8e8;
/* -webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease; */
}
.tile-box {
padding: 15px !important;
/* display: block !important; */
}
.tile-box::after {
content: "";
position: absolute;
width: 0;
height: 0;
top: 32px;
left: 0px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-width: 8px;
border-style: solid;
border-color: transparent transparent white white;
-webkit-transform-origin: 0 0;
-webkit-transform: rotate(45deg);
-ms-transform-origin: 0 0;
transform-origin: 0 0;
-ms-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-box-shadow: -3px 2px 2px rgba(0, 0, 0, 0.05);
box-shadow: -3px 2px 2px rgba(0, 0, 0, 0.05);
}
.tile-box1{
display:block;
}
<div class="content">
<div class="box">
<h1>box 1</h1>
<div class="tile-box">
<p>lorem ipsum dolor</p>
</div>
</div>
<div class="box">
<h1>box 2</h1>
<div class="tile-box">
<p>lorem ipsum dolor</p>
</div>
</div>
<div class="box">
<h1>box 3</h1>
<div class="tile-box">
<p>lorem ipsum dolor</p>
</div>
</div>
<div class="box">
<h1>box 4</h1>
<div class="tile-box">
<p>lorem ipsum dolor</p>
</div>
</div>
</div>
Codepen Url: (https://codepen.io/uibeast/pen/yLJgJra)
