我的 sass 遇到了问题。我一直在问候一个未定义的变量错误,我不确定为什么。该代码旨在使我的导航栏后面的指示器在光标悬停时更多。有任何想法吗?
错误如下:
Error: Undefined Variable: "$i". on Line 93 of style.sass.
下面是SASS代码:
$menu-items: 5
$menu-items-loop-offset: $menu-items - 1
$width: (100/$menu-items) * 1%
.with-indicator
@for $i from 1 through $menu-items-loop-offset
.Nav-item:nth-child(#{$i}).is-active ~ .Nav-item:last-child:after
left: ($width*$i)-$width
.Nav-item:nth-child(#{$i}).is-active ~ .Nav-item:last-child:before
left: ($width*$i)+($width/2)-$width
@for $i from 1 through $menu-items-loop-offset
.Nav-item:nth-child(#{$i}):hover ~ .Nav-item:last-child:after
left: ($width*$i)-$width !important
.Nav-item:nth-child(#{$i}):hover ~ .Nav-item:last-child:before
left: ($width*$i)+($width/2)-$width !important
.Nav-item
&:last-child
&:hover, &.is-active
&:before
left: (100%-$width)+($width/2) !important
&:after
left: 100%-$width !important
在此先感谢您的帮助。