css - 手写笔查找哈希名称

标签 css hash lookup stylus for-in-loop

有没有办法使用 Stylus lookup 函数在 for-in 循环中应用哈希?

$badge-photo-S   = {
  size: 36px
  font-size: 16px
} 
$badge-photo-XS  = {
  size: 32px
  font-size: 13px
}
.s-badge
  &-photo
    for each in S XS
      &--{each}
        {lookup('$badge-photo-'+each)}

它应该屈服于:

.s-badge-photo--S {
  width: 36px
  height: 36px;
  font-size: 16px;
} 

.s-badge-photo--XS {
  width: 32px
  height: 32px;
  font-size: 13px;
} 

但它提供了一个空输出。

最佳答案

您需要将lookup 的结果保存到一个变量中,然后在{} 中使用它:

$badge-photo-S   = {
  size: 36px
  font-size: 16px
} 
$badge-photo-XS  = {
  size: 32px
  font-size: 13px
}
.s-badge
  &-photo
    for each in S XS
      &--{each}
        hash = lookup('$badge-photo-'+each)
        {hash}

关于css - 手写笔查找哈希名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32903135/

相关文章:

html - Jekyll site.baseurl 在永久链接中丢失

hash - 用二叉搜索树实现哈希表

javascript - 覆盖图像属性

html - 文本区域标签的定位

c - 64 到 16 位哈希键

Ruby - 如何用数组值反转哈希?

performance - 为数百万项创建完美的哈希 - 结果只需要是 "exists or not"

c - 嵌入式软件 - 为什么查找表中需要 'const'?

methods - 编译器/解释器设计 : should built in methods have their own Node or should a lookup table be used?

html - 两个 block : one with dynamic width, 一个宽度相同 动态一个