less

Concatenate strings in Less

纵然是瞬间 提交于 2019-11-27 06:46:31
I think this is not possible, but I thought I ask in case there is a way. The idea is that I have a variable for path to web resource folder: @root: "../img/"; @file: "test.css"; @url: @root@file; .px { background-image: url(@url); } I get this as a result: .px { background-image: url("../img/" "test.css"); } But, I want the strings to combine into one string like this: .px { background-image: url("../img/test.css"); } Is it possible to concatenate strings together in Less? Paulpro Use Variable Interpolation : @url: "@{root}@{file}"; Full code: @root: "../img/"; @file: "test.css"; @url: "@

How can I compile LESS files within browser

╄→гoц情女王★ 提交于 2019-11-27 06:43:32
问题 I created code for switching themes using LESS functionality. Unfortunately the LESS files will not compile in browser. How can I compile LESS files within browser? 回答1: This is a piece of documentation: Client-side usage Link your .less stylesheets with the rel set to “stylesheet/less”: <link rel="stylesheet/less" type="text/css" href="styles.less"> Then download less.js from the top of the page, and include it in the <head> element of your page, like so: <script src="less.js" type="text

css, change less variable with @media

可紊 提交于 2019-11-27 06:42:37
问题 I'm currently on a site project that is responsive and less is really helping out a lot. But I want a size variable to change depending on window size. I've tried the following code, but it doesn't seem to work. Is this possible, or should I try another aproach? @menu-width: 300px; // default size @media only screen and (max-width: 400px) { @menu-width: 100px // smaller size } .menu { width: @menu-width; } 回答1: Since I don't seem to be getting a lot of support for closing this as a duplicate

Does LESS have an “extend” feature?

泄露秘密 提交于 2019-11-27 06:35:10
SASS has a feature called @extend which allows a selector to inherit the properties of another selector, but without copying the properties (like mixins). Does LESS have this feature as well? jonschlinkert Yes, Less.js introduced extend in v1.4.0 . :extend() Rather than implementing the at-rule ( @extend ) syntax used by SASS and Stylus, LESS implemented the pseudo-class syntax, which gives LESS's implementation the flexibility to be applied either directly to a selector itself, or inside a statement. So both of these will work: .sidenav:extend(.nav) {...} or .sidenav { &:extend(.nav); ... }

How do I extend a class/mixin which has dynamically formed selector

帅比萌擦擦* 提交于 2019-11-27 05:37:19
How do I extend a Less class which is dynamically formed using & combinator? Less which generates expected output: .hello-world { color: red; } .foo { &:extend(.hello-world); font-size: 20px; } Expected CSS output: .hello-world, .foo { color: red; } .foo { font-size: 20px; } Less does not generate expected output: .hello { &-world { color: red; } } .foo { &:extend(.hello-world); font-size: 20px; } Unexpected CSS output: .hello-world { color: red; } .foo { font-size: 20px; } Extending a dynamically formed selector (loosely using the term) like that is currently not possible in Less. There is an

Open a file in Visual Studio's CSS Source Editor

牧云@^-^@ 提交于 2019-11-27 05:33:35
问题 I am using Phil Haack's T4CSS T4 template based on .less One bad thing about Phil's solution is that visual studio opens the .less files as plain text files rather than as css files. (Thus no intellisense.) How can I get VS to open a .less file in the CSS Source Editor? I've tried: Right Click > Open With, but the CSS Source Editor isn't listed. Tools > Options > Text Editor > File Extensions, but once again, CSS Source Editor isn't listed. Can this be done? 回答1: I just posted an extension

Bootstrap variable overriding with LESS

南笙酒味 提交于 2019-11-27 05:30:39
问题 I have been investigating for the whole day as I considered it would be worthwhile spending some time to learn best practice for customizing Bootstrap. I can see that there is a friendly page available for customizing elements selectively from http://twitter.github.io/bootstrap/customize.html but I want to have more control than this without touching original bootstrap source files. To start with, I basically wanted to test out changing the grid from 12 to 16 columns and to do this, I created

Less/Sass debugging in Chrome Dev Tools/Firebug [closed]

ε祈祈猫儿з 提交于 2019-11-27 05:20:53
问题 How do you guys do maintenance on CSS built with Less/Sass? One of the things I like about Dev Tools/Firebug is the ability to see the line number of a css styling. Is there a good way to do this with CSS preprocessors other than having to manually search through the .less/.scss file to find the code I want to modify? 回答1: Chrome Developer Tools now supports Sass debugging out-of-the-box. Updated to include source maps: Previous versions used inline comment in your css to provide a refernce

LESS CSS: abusing the & Operator when nesting?

Deadly 提交于 2019-11-27 05:17:02
Less uses the & Operator to enhance the possibilities for nesting . .header { color: black; .navigation { font-size: 12px; &.class { text-decoration: none } } } which causes a substitution of the & with the parent selector and results in a concatentation of the actual selector right to the parent selector: .header .navigation.class instead of the normal appending, which would result in .class being a decendant: .header .navigation .class . Now what also is possible is the following ( see also here ): .header { color: black; .navigation { font-size: 12px; #some-id & .foo { text-decoration: none

WebStorm怎么设置实现自动编译less文件

♀尐吖头ヾ 提交于 2019-11-27 05:12:53
首先,需要保证电脑安装过Node.js ,下载地址: https://nodejs.org/en/ 安装Node.js的时候会自动安装npm 然后,安装lessc模块 打开cmd控制台 输入下面一行npm命令,安装less模块:-g是全局安装,如果不加会安装在当前目录。 npm install less -g 安装less-plugin-clean-css插件 (less的插件,用于压缩代码) npm install less-plugin-clean-css -g PHPStorm 点击File>Settings>Tools>File Watcher 添加less自动编译参数 PhpStrom会自动识别lessc.cmd文件,如果不能识别,手动找到npm目录的lessc.cmd文件即可,我这里添加的--clean-css参数会自动代码压缩,也可以不加,就不会自动压缩代码了。 这样在项目里编辑less文件时,会自动时时生成css文件了 效果如下: 来源: https://www.cnblogs.com/zcpblog/p/11346123.html