I tried to reproduce my situation in codepen . Below is the executable code.
The principle is as follows:
- Hover red square, it expands.
- As expanded, click on the center, after the click does not move the cursor .
- After the click, another square appeared in place of red, its former size. If you try to turn the mouse over this small square, the red hover will disappear and it will decrease in size.
So, how after a click to complete the hover on the red square, so that its transition returns to its original position? If you do not turn the mouse, the red box will be displayed after the click.
The markup cannot be changed at all , I count on the solution through js by 90%, the rest is css, but here it is unlikely he will be able to help ...
$(".one, .two").click(function(){ $(".two").toggleClass('show'); }); html { height: 100%; } html body { display: flex; justify-content: center; align-items: center; padding: 0; margin: 0; position: relative; height: 100%; } html body span { display: block; width: 100px; height: 100px; transition: all 300ms ease 0s; } html body .one { background-color: red; } html body .one:hover { width: 120px; height: 120px; } html body .two { position: absolute; background-color: blue; top: 0; left: 0; right: 0; bottom: 0; margin: auto; opacity: 0; visibility: hidden; } html body .two.show { opacity: 0.5; visibility: visible; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <span class="one"></span> <span class="two"></span>