JSFiddle - React, Tailwind, and code Playground

by Marco

HTML

<div class="selectBox" >
        <div class="foo" id="option1" style="background-color:green;"><span>Select option 1</span></div>
        <div class="foo" id="option2" style="background-color: black;"><span>Select option 2</span></div>
        <div class="foo" id="option3"  style="background-color:yellow;"><span>Select option 3</span></div>
        <div class="foo" id="option4" style="background-color:blue;"><span>Select option 4</span></div>
    </div>

CSS

*{
	margin: 0px;
	padding: 0px;
}

.selectBox{
	width:414px;
	height:414px;
	margin: auto;
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
}

.foo {
	width: 200px;
	height: 200px;
	border-width: 1px;
	border-style: solid;
	border-color: rgba(0,0,0,.2);
	position:absolute;
	-webkit-transition: all 0.3s ease-in;
	-moz-transition: all 0.3s ease-in;
	-o-transition: all 0.3s ease-in;
	-ms-transition: all 0.3s ease-in;
}

#option1{
	left: 0px;
	top: 0px;	
}

#option2{
	top: 0px;
	right: 0px;
}

#option3{
	left: 0px;
	bottom: 0px;
}

#option4{
	right: 0px;
	bottom: 0px;
}

.foo span{
	font-size: 1.4em;
	font-weight: bold;
	color: #333;
	background-color: #096;
	display: none;
	height: 30px;
	width: 100%;
	margin-top:85px;
	text-align: center;
}

.foo:hover span{
	display:block;
}

.rotate{
	-moz-transform:rotate(10deg);
	-webkit-transform:rotate(10deg);
	-o-transform:rotate(10deg);
	-ms-transform:rotate(10deg);
	transform:rotate(10deg);
}

JavaScript

var colors=['green','black','yellow','blue']
	$('.foo').hover(function(){
		var str = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')'
		$(this).css({'background-color':str}).addClass('rotate')
		},function(defaultColor){
			var ind=$(this).index()	
			$(this).css({'background-color':colors[ind]}).removeClass('rotate')
		})