I want to move pseudo-element when we hover on the current div. Here pink color div I want to move vertically in front of the currently hovered div. Can anyone suggest to me how can I achieve this output
$(document).ready(function() {
$(".timeline-entry").hover(function(e) {
e.preventDefault();
$('.timeline-entry.current').removeClass('current');
$(this).addClass('current');
});
});
.timeline {
position: relative;
display: flex;
flex-direction: column;
}
article {
width: 100px;
height: 50px;
background: red;
}
.timeline-entry.right-aligned {
align-self: flex-end;
background: blue;
}
.timeline-entry.left-aligned {
float: left;
}
.timeline:after {
content: '';
position: absolute;
top: 0;
left: 50%;
width: 20px;
height: 50px;
background: pink;
}
/* .timeline-entry:hover .timeline:nth-child(1) .timeline:after {
top: 100px;
} */
.timeline-entry.current {
background: yellow;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<div class="timeline">
<article class="timeline-entry right-aligned"></article>
<article class="timeline-entry left-aligned"></article>
<article class="timeline-entry right-aligned"></article>
<article class="timeline-entry left-aligned"></article>
</div>

attr()function but it has limited support for properties other thancontent- charlietfl:after? You could even animate a real element - charlietfl:afterselector will do it nicely. - Gil