JSFiddle - React, Tailwind, and code Playground

by Jean-Baptiste Audras

HTML

<div id="a"> A </div>
<div id="b"> B </div>

CSS

#a { 
    float: left; 
    width: 50%; 
    background: red; 
    height: 40px; 
}
#b { 
    float: right; 
    width: 50%; 
    background: green; 
    height: 40px; 
}

JavaScript

$('#a').hover(
    function(){
        $(this).animate({width: '60%'});
        $('#b').animate({width: '40%'});
    },
    function(){
        $(this).animate({width: '50%'});
        $('#b').animate({width: '50%'});
    }
);

$('#b').hover(
    function(){
        $(this).animate({width: '60%'});
        $('#a').animate({width: '40%'});
    },
    function(){
        $(this).animate({width: '50%'});
        $('#a').animate({width: '50%'});
    }
);