Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap (宽度:w,高度:h)在引导scss大小文件中迭代什么?_Twitter Bootstrap_Bootstrap 4_Sass - Fatal编程技术网

Twitter bootstrap (宽度:w,高度:h)在引导scss大小文件中迭代什么?

Twitter bootstrap (宽度:w,高度:h)在引导scss大小文件中迭代什么?,twitter-bootstrap,bootstrap-4,sass,Twitter Bootstrap,Bootstrap 4,Sass,我试图理解bootstrap utilities/_sizing.scss文件,但我不理解其中的第一个for循环。宽度和高度值来自何处?在引导scss文件夹中,您可以找到在_variable.scss文件中声明的$size值 // This variable affects the `.h-*` and `.w-*` classes. $sizes: () !default; $sizes: map-merge( ( 25: 25%, 50: 50%, 75: 75%

我试图理解bootstrap utilities/_sizing.scss文件,但我不理解其中的第一个for循环。宽度和高度值来自何处?

在引导scss文件夹中,您可以找到在_variable.scss文件中声明的$size值

// This variable affects the `.h-*` and `.w-*` classes.
$sizes: () !default;
$sizes: map-merge(
  (
    25: 25%,
    50: 50%,
    75: 75%,
    100: 100%,
    auto: auto
  ),
  $sizes
);
下面是循环说明:

@each $prop, $abbrev in (width: w, height: h) {
  @each $size, $length in $sizes {
    .#{$abbrev}-#{$size} { #{$prop}: $length !important; }
  }
}
在第一个示例中,每个宽度和高度是$prop,w和h是$abbrev。 第二个循环迭代来自_variables.scss文件的$size和$length

// This variable affects the `.h-*` and `.w-*` classes.
$sizes: () !default;
$sizes: map-merge(
  (
    25: 25%,
    50: 50%,
    75: 75%,
    100: 100%,
    auto: auto
  ),
  $sizes
);
$size值为(25,50,75100,自动)
$length值为(25%、50%、75%、100%,自动)

结果是它生成了宽度和高度的所有类的组合,其大小和长度如下所示:

.w-100{ //where w is the $abbrev and 100 is the $size
    width:100%; //where width is the $prop and 100% is the $length
}
然后,如您所知,您可以将这些类应用于html,如下所示:

<div class="w-100"></div> <!-- A 100% width div -->

字面上是
w
h
,导致w-100、h-100、w-50、h-50等。。。