热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Twitter引导的多重转换。转换?-MultipletransitionsforTwitterbootstrap.transition?

IamwantingtoanimatetwopropertiesinBootstrapv2.1.0,我想让Bootstrap2。0中的两个属性动起来,Theopacity

I am wanting to animate two properties in Bootstrap v2.1.0,

我想让Bootstrap 2。0中的两个属性动起来,

The opacity and the margin.

不透明度和边缘。

I have tried:

我有尝试:

.transition(opacity 0.5s, margin 0.25s);: No output
.transition('opacity 0.5s, margin 0.25s');: Invalid CSS output
.transition(opacity 0.5s); .transition(margin 0.25s);: Margin overrides opacity.

.transition(不透明度为0.5秒,边缘为0.25秒);:无输出。transition('不透明度为0.5秒,边缘为0.25秒');:无效的CSS输出。transition(不透明度为0.5秒);.过渡(边缘0.25秒);:边缘覆盖不透明度。

Note that I am using lessphp so solutions that use the Javascript regex will not work.

注意,我使用的是lessphp,因此使用Javascript regex的解决方案将不起作用。

I know I could copy the mixin and modify it to accept two parameters as well, but that just seems hacky, surely there is a better way?

我知道我可以复制mixin并修改它以接受两个参数,但这似乎很陈腐,肯定有更好的方法吗?

1 个解决方案

#1


63  

Two Options (Depending on version of LESS)

LESS (1.3.3+)

少(1.3.3 +)

The less2css.org shows this works with LESS 1.3.2 on experimentation, but the issue documentation seems to indicate this is a 1.4 release addition.

less2css.org显示,在实验上使用的方法少于1.3.2,但是问题文档似乎表明这是1.4版本的增加。

Whenever it became effective, at some point, the semicolon was introduced as a possible variable separator in parametric mixins while still allowing commas. The presence of a ; causes commas to be viewed not as separating variables, but rather as part of the value of the variable itself (a comma separated list). This then allows (to quote the site) us to use a "dummy semicolon to create mixin call with one argument containing comma separated css list."

当它变得有效时,在某些点上,分号作为参数混合中可能的变量分隔符引入,同时仍然允许使用逗号。a的存在;使逗号不被视为分隔变量,而是作为变量本身的值(逗号分隔的列表)的一部分。这就允许(引用站点)我们使用一个“虚拟分号创建mixin调用,其中包含一个包含逗号分隔的css列表的参数。”

Therefore the following works to produce the same output as above without the escaped string (NOTE the "dummy" semicolon put at the end of the variable entry, right before the closing parenthesis of the parametric mixin call):

因此,以下操作可以在不使用转义字符串的情况下产生与上面相同的输出(请注意,在变量项的末尾,参数mixin调用的结束圆括号之前放置的“哑”分号):

.transition(opacity 0.5s, margin 0.25s;);
                                      |
                                semicolon here

LESS (pre 1.3.3, but also works in later versions)

更少(1.3.3之前,但也适用于以后的版本)

Do a string interpolation (~) for the passed in variables:

对传入的变量做一个字符串插值(~):

.transition(~"opacity 0.5s, margin 0.25s");

Both solutions output:

这两个解决方案输出:

-webkit-transition: opacity 0.5s, margin 0.25s;
-moz-transition: opacity 0.5s, margin 0.25s;
-o-transition: opacity 0.5s, margin 0.25s;
transition: opacity 0.5s, margin 0.25s;

推荐阅读
author-avatar
迷途羔羊1989_751
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有