JSFiddle - React, Tailwind, and code Playground

by ElenaOr

HTML

<ul>
  <li class="red"></li>
  <li class="green"></li>
  <li class="pink"></li>
</ul>

<div class="big-color hidden"><div>

CSS

ul {
  padding: 0;
  margin: 0;
  list-style-type: none;
  display: flex;
  flex-direction: row;
}

li {
  margin: 80px;
  width: 20px;
  height: 20px;
}

.red {
  background-color: red;
}

.green {
  background-color: green;
}

.pink {
  background-color: pink;
}

.big-color {
 width: 100px;
  height: 100px;
  background-color: yellow;
  position: absolute;
}

.hidden {
  display: none;
}

JavaScript

var colorsBig = document.querySelector('.big-color');
var colorsElements = document.querySelectorAll('ul li');

for(var colorElement of colorsElements) {
	colorElement.onmouseenter = function() {
		colorsBig.classList.remove('hidden');
		var targetX = event.target;
		var location = targetX.getBoundingClientRect();
	}
	colorElement.onmouseleave = function() {
		colorsBig.classList.add('hidden');
	}
}