JSFiddle - React, Tailwind, and code Playground
HTML
<nav>
<ul>
<li>item1</li>
<li>hover me <br/>check box shadow on right side is missing because of z-index:1</li>
<li>i want this item to be over the tiny square always but also with box shadow on right side working</li>
<li>item4</li>
<li></li>
</ul>
<span>
</span>
</nav>
<h1>
Some fake text which must not move, hence the little square is positioned absolute
</h1>
<p>
1. Try removing z-index from li <br/>
2. Try having z-index on li hover only
</p>
SCSS
body {
background-color: gray;
}
h1 {color: white; text-align: center;}
nav {
margin: 30px;
}
ul {
list-style: none;
display: flex;
padding: 0;
margin: 0;
}
li {
flex-grow: 1;
flex-basis: 0;
padding: 0 15px;
min-height: 150px;
margin: 0 1px;
transition: all 0.3s ease-out;
background-color: white;
// adding z-index here makes shadow on the right side to dissapear
z-index: 1;
&:hover {
box-shadow: 0px 0px 65px -26px rgba(0, 0, 0, 0.75);
transform: scale(1.09);
// if using z-index on hover it has overlap at the end
//z-index: 1;
}
}
nav > span {
position: absolute;
left: calc(50% - 50px / 2);
background: white;
width: 50px;
margin: 0 auto;
box-shadow: inset 0px 6px 5px 0px grey;
height: 22px;
transition: all 0.3s ease;
&:hover {
cursor: pointer;
height: 28px;
margin-bottom: -3px;
box-shadow: inset 0px 3px 5px 0px grey;
}
}