当悬停在导航列表项(水平排列)上时,它会变大并获得一个边距以在它和与其相邻的其他列表项之间创建一个间隙,你如何使悬停的项目保持在其悬停前位置的中心,而相邻的项目向左和向右散开?以下是我目前拥有的代码(您也可以在CodePen上查看)。
谢谢, TJ
#nav {
list-style: none;
padding: 0;
margin: 0;
position: absolute;
top: 15px;
right: 15%;
font-weight: bold;
}
#nav:hover {
}
#nav li {
float: left;
padding: 5px 10px;
text-align: center;
}
li:first-child {
border-top: 4px solid white;
border-right: 2px solid white;
border-bottom: 4px solid white;
border-left: 4px solid white;
}
li:nth-child(2) {
border-top: 4px solid white;
border-right: 2px solid white;
border-bottom: 4px solid white;
border-left: 2px solid white;
}
li:nth-child(3) {
border-top: 4px solid white;
border-right: 2px solid white;
border-bottom: 4px solid white;
border-left: 2px solid white;
}
li:nth-child(4) {
border-top: 4px solid white;
border-right: 4px solid white;
border-bottom: 4px solid white;
border-left: 2px solid white;
}
#nav li:hover {
box-shadow:
2px 2px 6px rgba(0, 0, 0, 0.2),
-2px -2px 6px rgba(0, 0, 0, 0.2),
-2px 2px 6px rgba(0, 0, 0, 0.2),
2px -2px 6px rgba(0, 0, 0, 0.2);
z-index: 5;
text-align: center;
background-color: white;
color: black;
border: 4px solid rgba(0, 0, 0, 0.2);
font-size: 1.2em;
margin: 0 10px;
}