加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap-3 – .box-shadow值前面的Tilde

发布时间:2020-12-17 20:45:06 所属栏目:安全 来源:网络整理
导读:我正在看看bootsrap mixins.less并注意到盒子阴影值前面的波浪号.它有什么用途?如果我的网站支持IE9,我应该使用它吗? .box-shadow(~"inset 0 1px 1px rgba(0,.075),0 0 8px @{color-rgba}"); 解决方法 这是代字号 – 引用CSS escaping. In LESS,a tilde ~
我正在看看bootsrap mixins.less并注意到盒子阴影值前面的波浪号.它有什么用途?如果我的网站支持IE9,我应该使用它吗?

.box-shadow(~"inset 0 1px 1px rgba(0,.075),0 0 8px @{color-rgba}");

解决方法

这是代字号 – 引用CSS escaping.

In LESS,a tilde ~ before a string "" literal outputs the string
as-is,because it may be a syntax error in pure LESS.

在this particular instance中,它用于转义逗号,字符串属于box-shadow属性的多个值.

因为逗号用于分隔较少mixins的参数.所以他们做了:

.foo {
  .box-shadow(~"inset 0 1px 1px rgba(0,0 0 8px @{color-rgba}");
}

或者,他们可以将值列表传递给.box-shadow()mixin.

从doc:

if the compiler sees at least one semicolon inside mixin call or
declaration,it assumes that arguments are separated by semicolons and
all commas belong to css lists

use dummy semicolon to create mixin call with one argument containing
comma separated css list: .name(1,2,3;)

因此,他们可以在值的末尾使用分号,以使编译器将其视为列表:

.bar {
  .box-shadow(
    inset 0 1px 1px rgba(0,0 0 8px @color-rgba;
                  //  They could append a semicolon here ^
  );
}

与以下内容相同:

.bar {
  @list: inset 0 1px 1px rgba(0,0 0 8px @color-rgba;
  .box-shadow(@list);
}

这是上述方法的an example.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读