I am new to Sass and would like to use an if statement to find an existing class in an element to generate the appropriate css.
My installation has a large number of Javascript-generated images that are assigned a unique identifier, as well as a βpictureβ class and a randomly assigned class from the top, right, bottom or left.
I also use a random function for Sass (here: https://gist.github.com/chriseppstein/1561650 ) and would like a different value to be assigned to each identifier, so that each element is in random order.
My SCSS has the following, which positions the images based on which class was assigned:
@for $i from 0 through $number-of-pictures {
This works well, but creates a ton of unused ad units. For example, # picture-38 was assigned the class ".top", so all I need is the first block of the declaration, but CSS exports all the parameters:
#picture-38.top { left: 38px;
I need an if statement that determines if an element has a class before parsing css. Sort of:
@if "#picture-#{$i} has class $class-top" { &.top { left: random($stage-width); } }
Any ideas?
source share