less

Dynamically define a variable in LESS CSS

你离开我真会死。 提交于 2019-11-28 09:14:19
I am trying to create a mixin that dynamically defines variables in LESS CSS, by actually assigning them a composite name. The simplified use-case (not the real one): .define(@var){ @foo{var}: 0; } Then one would call the mixin as such: .define('Bar'){ @fooBar: 0; } Since this kind of string interpolation is possible while using selectors names, I was wondering if the same would be possible for variable names; so far, I have had no luck with various syntaxes I tried (other than the above, I tried escaping, quoting, using the ~ prefix and so on). Edit I just tried one more thing, and I feel I

How to set keyframes name in LESS

半世苍凉 提交于 2019-11-28 08:57:21
I try to set up this LESS mixin for CSS animation keyframes: .keyframes(@name, @from, @to) {; @-webkit-keyframes "@name" { from { @from; } to { @to; } } } but there is some problem with name pharse, is there any option to do this corectly? As of LESS >= 1.7 you can use variables for keyframe keywords (names). Some changes have been made in LESS 1.7 to how directives work, which allows to use variables for the name/keyword of @keyframes (so the example from the question should work now). DEMO Unfortunately keyframes names can not be dynamically generated in LESS <= 1.6 Hence, the normal way of

add a rule to an element only if it has a certain child

大憨熊 提交于 2019-11-28 08:43:45
问题 Is there a way of adding CSS rules to an element only if it has an certain child element ? I do know it is not possible to do it with CSS, but I'm not sure if it is possible to do it with LESS. 回答1: If it is not possible with CSS, then it is not possible with LESS, which compiles to plain old vanilla CSS. The problem is, that the LESS is compiled without knowledge of the HTML it is applied to, and without any client side scripting. Therefore, it is impossible to achieve anything with LESS

Concatenate string and var less css

蹲街弑〆低调 提交于 2019-11-28 08:20:53
Can anyone please tell me how to concatenate a var and a string in LESS so I don't have the space between them? I have the following code: .text(@size) { font-size: @size + px; line-height: (@size / 10) + em; } h1 { .text(16) } What the LESS outputs is the following: h1 { font-size: 12 px; line-height: 1.2 em; } I need to find a way to remove the spaces. Thanks Pete In case any late-comers find this thread: There is a built-in function for this: unit(@dimension, [@unit: ""]); So font-size: unit(@size, px); should result in font-size: 12px . I tested it. http://lesscss.org/#reference U can use

PHPStorm: How do I setup LESS to output to CSS directory with file watcher?

不羁岁月 提交于 2019-11-28 08:11:47
How do, using File Watchers in PHPStorm do I set up LESS file watchers output path to do this: I want: /project/path/less/dir/file.less to output to: /project/path/css/dir/file.css or /project/path/less/file2.less to output to: /project/path/css/file2.css I'm not seeing a clear way to make this happen with the Output Path macros in PHPstorm. With the FileDirRelativeToProjectRoot macro, I'm able to get the path to the current directory, but there is no clear way to replace /less with /css in the path. CrazyCoder See my related answer for JADE file watcher , I believe it would be the same for

Tilde in front of .box-shadow value

血红的双手。 提交于 2019-11-28 08:01:39
问题 I was looking at bootsrap mixins.less and noticed a tilde in front of box-shadow value. What purpose does it serve? If my website supports IE9 and higher should I be using it? .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}"); 回答1: That is the tilde-quote 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. In this particular instance, it's used in order to escape the comma , character at the

LESS: Extend a previously defined nested selector

谁说我不能喝 提交于 2019-11-28 07:51:45
问题 I've been trying like a mad man to get the following LESS statement to work, but now i am fearing that it's not gonna happen :/ So I am turning now to you guys in the end for help! I have the following statement: .top{ &-first{ background:black; &-item{ color:white; } } &-second{ background:green; &-item:extend(.top-first-item){} } } I was hoping for to achive the following output: .top-first { background: black; } .top-first-item, .top-second-item{ color: white; } .top-second { background:

Twitter's Bootstrap 3.x semantic mobile grid

青春壹個敷衍的年華 提交于 2019-11-28 07:45:21
After reading the new (unfinished) Bootstrap 3 docs I am wondering how to create semantic mobile grid. In short. How to convert this: <div class="row"> <div class="col col-lg-6 col-sm-6">6</div> <div class="col col-lg-6 col-sm-6">6</div> </div> To this and preserve the small mobile grid: <div class="wrapper"> <div class="left">6</div> <div class="right">6</div> </div> Less .wrapper { .make-row(); } .left { .make-column(6); // this creates only large grid } .right { .make-column(6); } Bass Jobsen If i understand your question well i think you should use: <div class="row"> <div class="col-span-6

Read hex data into less

北城余情 提交于 2019-11-28 07:05:37
问题 I want to give a big data file to less -s -M +Gg such that read current given data in less -s -M +Gg . While-loop example (see ntc2's answer) Less command explained here. Replacing the yes by a binary file which is converted to binary ascii and hex: while read -u 10 p || [[ -n $p ]]; do hexdump -e '/4 "%08x\n"' {$p} \ \ | less -s -M +Gg done 10</Users/masi/Dropbox/7-8\:2015/r3.raw where the looping is based on this thread here. How can you read such data into less? 回答1: I don't understand the

Variable Name Error “is undefined” even though “variables.less” imported

谁说我不能喝 提交于 2019-11-28 06:42:56
I started using LESS today. But it's kinda weird. This code does not work. I get an error: ! Variable Name Error: @linkColor in a is undefined. My bootstrap: @import "variables.less"; @import "normalize.less"; variables.less: @linkColor: #08c; @linkColorHover: darken(@linkColor, 15%); normalize.less: a { color: @linkColor; } a:visited { color: @linkColor; } a:hover { color: @linkColorHover; } When I make an @import "variables.less" in the normalize.less file, everything works fine. Thanks for your help :) Chris Jaynes This other question ultimately led me to the right answer. It looks like the