I have two absolute positioned elements. One is a dot and the other is a box with just corners - both are animated. I'd like the dot to always be in the center of the cornered box that shows on hover. But the issue I'm having is when I make the browser window small the cornered box is slightly to the left and when I make it large the cornered box is slightly to the right. Both elements have fixed widths and both are positioned with percents. What did I do wrong? Here is what I have:
.wrapper {
position: relative;
width: 100%;
min-height: 500px;
background: blue;
}
.pulse {
position: absolute;
top: 41.8%;
left: 45.614%;
display: block;
width: 22px;
height: 22px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.8);
cursor: pointer;
box-shadow: 0 0 0 rgba(255, 255, 255, 0.4);
animation: pulse 2s infinite;
}
.pulse:hover {
animation: none;
}
.pulse:hover+.corners {
visibility: visible;
transform: scale(2);
transition: all .6s;
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
}
70% {
box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
}
}
.corners {
position: absolute;
top: 43.65%;
left: 46.35%;
pointer-events: none;
visibility: hidden;
}
.corners:before {
display: block;
content: "";
width: 5px;
height: 5px;
position: absolute;
top: -10px;
left: -10px;
border-top: 1px solid #FFF;
border-left: 1px solid #FFF;
}
.corners:after {
display: block;
content: "";
width: 5px;
height: 5px;
position: absolute;
top: -10px;
right: -10px;
border-top: 1px solid #FFF;
border-right: 1px solid #FFF;
}
.corners-inner:before {
display: block;
content: "";
width: 5px;
height: 5px;
position: absolute;
bottom: -10px;
left: -10px;
border-bottom: 1px solid #FFF;
border-left: 1px solid #FFF;
}
.corners-inner:after {
display: block;
content: "";
width: 5px;
height: 5px;
position: absolute;
bottom: -10px;
right: -10px;
border-bottom: 1px solid #FFF;
border-right: 1px solid #FFF;
}
<div class="wrapper">
<span class="pulse"></span>
<div class="corners"><span class="corners-inner"></span></div>
</div>