less

less-css — is it possible to get a parent's parent?

人盡茶涼 提交于 2019-11-29 12:27:19
问题 Is it possible to get a parent's parent? I tried & & { } but that didn't work. I'm trying to style a child element based on it's grandparent. 回答1: Depends on Code Structure, and may Require Some Repetition of Code You cannot do it directly in most cases (see second example for exception). If Grandparent is an element This requires some repetition, but does allow for the grandparent to not be the outermost wrapper (so there could be a great grandparent). LESS grandparent { /* grandparent

Less multiple files import

本秂侑毒 提交于 2019-11-29 12:20:35
I'm working on WordPress theme that needs to have color schemes functionality. I am forced to use less on this project. I have file called schemes.less, that contains code for styling different colored sections on a webpage. Then I have set of less files called: dark.less, light.less, blue.less etc. I am importing them using default values technique ( http://lesscss.org/features/#variables-feature-default-variables ), but because of lazy loading if I import the scheme.less multiple times every time I have the same variables. Are there any ways to workaround that? Isolate themes from each other

SimpLESS won't compile initializr generated Bootstrap

元气小坏坏 提交于 2019-11-29 11:33:08
I just downloaded an intializr generated version of Bootstrap. I also installed SimpLESS to keep from having to constantly having to manually recompile my LESS files and to avoid using the in-browser compiler. SimpLESS however, refuses to compile the very basic style.css file in my directory. It spits up: Result of expresiin style.less on 'e.message' [undefined] is not an object. Note: "Expression" is indeed spelled the way it appears above. My style.less file currently looks like this: @import "bootstrap/bootstrap.less"; body { padding-top: 60px; padding-bottom: 40px; } @import "bootstrap

Vue中如何使用less

筅森魡賤 提交于 2019-11-29 11:17:26
最近发现好多小伙伴在面试的过程中会问到vue如何使用less和scss,所以我绝对更新、复习一下less;废话不多说直接进主题; 依赖下载 1、首先使用npm下载依赖; npm install --save less less-loader 2、安装完成后检查是否安装成功; lessc -v    3、如果安装成功后,会显示安装成功后的版本; 引用方法 1、在main.js import less from 'less' Vue.use(less) 2、然后创建一个.vue文件我们开始玩耍了; 注意:独立的vue文件需要引入less <style lang="less"></style> 开始使用 1、less中变量的使用; 在less,允许我们使用以变量的形式来定义,定义方式:@k:v; 使用方式:@k; <div class="box"></div> <style lang="less"> @color:red; @k:100px; .box{ width:@k; height:@k; background: @color; } </style> 此时就会有一个宽100px,高100px,背景红色的正方形显示在页面上了; 2、字符串拼接变量使用方式; <div class="box1"></div> <style lang="less" scoped> @img:'./img/

Using Less in a Rails 3.1 App

ぃ、小莉子 提交于 2019-11-29 11:12:38
问题 I've just upgraded my application to the latest release of rails (3.1) and I'm wanting to integrate Twitter's Bootstrap into my application but it uses LESS and not SASS which is what Rails 3.1 uses by default. How do I go about configuring Rails to use Less instead of Sass? 回答1: As apneadiving points out, Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS. To configure your Rails app to support LESS, you can add the gem to the assets group of your Gemfile: group :assets do

Using LESS variables in media queries

孤者浪人 提交于 2019-11-29 10:54:50
When I enter the following less code: (paste it into http://less2css.org ) @item-width: 120px; @num-cols: 3; @margins: 2 * 20px; @layout-max-width: @num-cols * @item-width + @margins; @media (min-width: @layout-max-width) { .list { width: @layout-max-width; } } ... the resulting CSS is: @media (min-width: 3 * 120px + 40px) { .list { width: 400px; } } Notice that the same variable @layout-max-width - in the media query it produces an expression (which isn't what I want) and when used as the value for the width property it produces 400px (which is also what I want for the media query.) Is there

Less.js - strong nested rules?

拟墨画扇 提交于 2019-11-29 10:43:36
I love the ability of less.js to make nested rules. For example .A{ .B{ width:50px; } } which results in .A .B{ width:50px; } But is there a way to make it result in this: .A > .B{ width:50px; } I´ve already tried to do this: .A{ &>.B{ width:50px; } } But it does not work... Thanks! It's as simple as this: .A { > .B { width: 50px; } } Another related question: Immediate Child selector in LESS Some documentation: http://lesscss.org/features/#features-overview-feature-nested-rules (doesn't actually include relevant example) 来源: https://stackoverflow.com/questions/7634932/less-js-strong-nested

Negate a numerical variable and add 'px' to it in LessCSS

风格不统一 提交于 2019-11-29 10:43:33
问题 I would like to create a function which does the following: .sprite-size (@width,@height,@x,@y) { width:~'@{width}px'; height:~'@{height}px'; background: @sprites no-repeat -~'@{x}px' -~'@{y}px'; } I would like to pass a postive value, in @x and @y and then negate them in the output. The above LESS function outputs the following for the following example: //LESS .header-language-selection { .sprite-size(44,21,312,0); } //Outputs CSS .header-language-selection { width: 44px; height: 21px;

Convert px to em in Less

江枫思渺然 提交于 2019-11-29 10:28:28
问题 What is the equivalent of Scss' emCalc() in less? padding: emCalc(24px); in Scss will calculate em based on the viewpoint and zoom level. Is there any built-in function in less? 回答1: You could do this to convert px to em. @font-size: 16; // Your base font-size in pixels @em: @font-size*1em; // Shorthand for outputting ems, e.g. "12/@em" @rem: @font-size*1rem; // Shorthand for outputting ems, e.g. "12/@rem" h1{ font-size: 20/@em; } 回答2: With LESS you can build your own functions. I use this

escape whole declaration in less css

北城余情 提交于 2019-11-29 09:36:19
Is it possible to escape whole declaration? This complies fine in less.js (I'm using less.app) margin: e(" 0 10px"); But this throws an error: e("margin: 0 10px"); I've tried putting 'margin' in a variable but without success. Sorry that's not possible. A couple things though: The official escape designation (according to lesscss.org is the tilde-quote, not the e() syntax, like so: margin: ~"0 10px"; Second, the code you provided is not nearly complex enough to warrant a LESS CSS string literal. Please share the actual code that you are having trouble with. You may want to close this question