Hello, I'm building a SASS style structure that changes will depend on a defined class in my body. This class dictates which browser the user is using, for example:
<body class="chrome"> <!-- Google Chrome -->
<body class="firefox"> <!-- Mozilla Firefox -->
<body class="ie"> <!-- Internet Explorer -->
<body class="opera"> <!-- Opera Browser -->
<body class="edge"> <!-- Edge Browser -->
I'm aware that in CSS, if I want to change anything for each element, I should use a selector together like this:
In CSS
.chrome .foo { background-color:red; }
.firefox .foo { background-color:blue; }
.ie .foo { background-color:yellow; }
.opera .foo { background-color:pink; }
.edge .foo { background-color:green; }
In SASS (by logic)
.chrome {
.foo { background-color:red; }
}
.firefox {
.foo { background-color:blue; }
}
.ie {
.foo { background-color:yellow; }
}
.opera {
.foo { background-color:pink; }
}
.edge {
.foo { background-color:green; }
}
I would like to know if there is no more "readable" way to write directly to the Child element this modification based on the Parent class, something like this:
.foo {
parent(.chrome) { background:red; }
parent(.firefox) { background:blue; }
parent(.ie) { background:yellow; }
parent(.opera) { background:pink; }
parent(.edge) { background:green; }
}
Is there any way for me to define this in SASS and he himself will be responsible for assembling the rest of the statements for when, in a given class, he will find this?