Lighten parent (unknown) background color in child

Is there a less way or (css3 in general) to access the parent background-colorwithout knowing it?

Sort of:

.child-class {
    background-color: lighten(parent-background-color, 30%);
}

Less obvious would be the obvious approach, but in this case I just don't know the parent background-color, as it can be dynamically styled.

Has anyone gotten something in their stunt to help?

+2
source share
2 answers

EDIT: Take a look at Scott's answer for the smart decision you probably need.

css. , "" . , DOM , . - , css .

, , "" , CSS, "SASS" "LESS". . , ​​. , , css.

JavaScript , , jQuery. JavaScript/jQuery, , , , .

+3

"" . , "" ( "" ), , css3 rgba() opacity . ( ):

# 1: CSS3 rgba

.lighten {
    background-color: rgba(255, 255, 255, 0.3);
}

№2: CSS2

.lighten{
    position: relative;
    z-index: 0;
}

.lighten:before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: -1;
    background-color: #fff;
    opacity: 0.3;
}

. ,

+8

All Articles