I am looking for a purely CSS solution to the following problem.
I have a div that contains an indeterminate number of divs,
I'm looking for that given an RGB color, for example, (0,0,0)
and a range of opacity values (0.3 - 0.7)
will vary the opacity of the divs in that range progressively.
At the moment I have the following. Using the selectors first-child
and last-child
:
.container {
background : #f7f7f7;
padding : 10px;
}
.container div {
height : 30px;
margin : 5px;
background : rgba(0, 0, 0, .5);
}
.container div:first-child {
background : rgba(0, 0, 0, .3);
}
.container div:last-child {
background : rgba(0, 0, 0, .7);
}
<div class="container">
<div>aaa</div>
<div>aaa</div>
<div>aaa</div>
<div>aaa</div>
<div>aaa</div>
<div>aaa</div>
</div>
Is it possible using CSS only?