我有一个导航wine 吧,.navbar
英镑,有7个直系子女,navbar-item
英镑.
目前,我将其设置为当您将鼠标悬停在导航栏项目上时,它会将其宽度和高度增加20px.但我想要的是,当你将鼠标悬停在其中一件物品上时,它的高度和宽度会增加20px,它会增加Directly Neighboringdiv(所以左右div,除非它在边缘上),宽度和高度增加10px.
我想要的一个很好的例子就是MacOS应用程序栏效果.
代码:
body {
background-color: #D3D3D3;
}
.navbar {
width: 600px;
height: 50px;
border-radius: 999px;
background-color: white;
padding: 5px;
display: flex;
align-items: center;
justify-content: space-around;
}
.navbar-item {
border: 1px solid black;
height: 50px;
width: 50px;
border-radius: 50%;
}
.navbar-item:hover{
width: 70px;
height: 70px;
}
<div class="navbar">
<div class="navbar-item"></div>
<div class="navbar-item"></div>
<div class="navbar-item"></div>
<div class="navbar-item"></div>
<div class="navbar-item"></div>
<div class="navbar-item"></div>
<div class="navbar-item"></div>
</div>
我try 使用.navbar-item:hover + .navbar-item
,但这只是更改了实际悬停的div右侧的宽度和高度.
我读到了这个问题:How to affect other elements when one element is hovered
但它没有回答我的问题.