2
Hello, I am building a SASS style structure that changes will depend on a class set in my body. This class dictates which browser the user is using, 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 am 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 wonder if there is some more "readable way to write directly in the element Child this class-based modification Parent, something like that:
.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 I can define this in the SASS and make sure to assemble the rest of the statements for when, in a certain class he finds this?
in fact I found a way beem more functional, no extend..., see in the post I’m creating
– LeandroLuk
Posted here in this post for us to see =)
– Samuel Souza
tai the solution, functional, and simple... so I can do "bugfixe’s" within each element when needed
– LeandroLuk