Below is a example of how I want my final result will be, however in real life, <div class="item"></div>
is generated unknown number, so :nth-child(3)
and :nth-child(5)
this hard-coded style is not possible. active center
classes will always be in center child. So, is there any css way can style the child between <div class="item active center"></div>
body{
margin:0;
background-color:#333;
}
.container{
display:flex;
align-items:center;
}
.item{
height:50px;
width:50px;
background-color:#fff;
margin:10px;
opacity:0.2;
}
.item.active.center{
opacity:1;
}
.item.active:nth-child(3){
opacity:1;
}
.item.active:nth-child(5){
opacity:1;
}
<div class="container">
<div class="item"> </div>
<div class="item active"> </div>
<div class="item active"> </div>
<div class="item active center"> </div>
<div class="item active"> </div>
<div class="item active"> </div>
<div class="item"> </div>
</div>
Like this example
http://jsfiddle.net/4a5uhm6x/
instead of middle 1 opacity:1
, need middle of 3 child opacity:1