I have panel which I colored blue if this panel is being selected (clicked on it). Additionally, I add a small sign (.png
image) to that panel, which indicates that the selected panel has been already selected before.
So if the user sees for example 10 panels and 4 of them have this small sign, he knows that he has already clicked on those panels before. This work fine so far. The problem is now that I can't display the small sign and make the panel blue at the same time.
I set the panel to blue with the css background: #6DB3F2;
and the background image with background-image: url('images/checked.png')
. But it seems that the background color is above the image so you cannot see the sign.
Is it therefore possible to set z-index
es for the background color and the background image?
Based on MDN Web Docs you can set multiple background using shorthand
background
property or individual properties except forbackground-color
. In your case, you can do a trick usinglinear-gradient
like this:The first item (image) in the parameter will be put on top. The second item (color background) will be put underneath the first. You can also set other properties individually. For example, to set the image size and position.
Benefit of this method is you can implement it for other cases easily, for example, you want to make the blue color overlaying the image with certain opacity.
Individual property parameters are set respectively. Because the image is put underneath the color overlay, its property parameters are also placed after color overlay parameters.