A
A
Adex2017-08-21 21:44:31
Sass
Adex, 2017-08-21 21:44:31

How to loop through css property values?

Is there a way to loop over property values, such as box-shadows, to set the number of shadows, separated by commas, each time the offset increases by the given value?
Below is what was enough.

%craft {
  width: 27px; 
  height: 31px;
  display: block;
  margin-right: 10px;
  border: 1px solid black;
}
@for $i from 2 through 4 {	
  $start: 0px; 						//стартовое смещение
  $color: $line-background_color;		//цвет
  $length: $start - $i; 				//смещение тени
  
  $shadow: #{$length} #{$length} 0 #{$color};	//все параметры	
  
  
  @for $a from 3 through 5 {	
    $all: #{$shadow},;
    $test: #{$all} ,#{$shadow};


    @for $a from 5 through 7 {			
      $test: #{$shadow},#{$shadow};

      .craft {
        @extend %craft;	
        
        @include box-shadow($test);
      }
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2017-08-21
@Za0r

@function makelongshadow($color) {
$val: 0px 0px $color;
@for $i from 1 through 200 {
$val: #{$val}, #{$i}px #{$i}px #{$color};
}
return $val;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question