less

CSS pre-processor with a possibility to define variables in a @media query

我的梦境 提交于 2019-11-30 08:25:53
问题 Currently, I am using LESS as my main CSS pre-processor. I have (and I am sure a lot of people have this need) to define variables in a @media query like: @media screen and (max-width: 479px) { myVar: 10px; } @media screen and (min-width: 480px) and (max-width: 767px) { myVar: 20px; } @media screen and (min-width: 768px) { myVar: 30px; } .myElement { padding: @myVar; } This doesn't work in LESS, because of the compiling nature ( @myVar is defined within a scope of each particular @media only,

How to ignore certain LESS files in Web Essentials LESS compiling? (Bootstrap)

走远了吗. 提交于 2019-11-30 08:18:22
I've set up Web Essentials 2013 (in Visual Studio 2012) and loaded in the default Twitter Bootstrap LESS source files. Auto-build and minification is working perfectly, except Web Essentials quite overdoes the job. When I select " bootstrap.less ", make a change and save it, Web Essentials creates a new " bootstrap.css " as well as a " bootstrap.min.css " with everything inside I need. But when I edit e.g. buttons.less , it creates a buttons.css (and buttons.min.css ) too (with all the includes and mixins). Which means, in fact, I'll have nearly the same css files over and over again under

Using Less in a Rails 3.1 App

拟墨画扇 提交于 2019-11-30 08:12:27
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? 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 gem 'less' end Then, run bundle install to get the less gem and its dependencies (which includes the libv8

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

浪子不回头ぞ 提交于 2019-11-30 07:56:18
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; background: url('/Content/images/sprites.png') no-repeat - 312px - 0px; } As you can see the output result

Is there polyfill for css transform property in IE8

℡╲_俬逩灬. 提交于 2019-11-30 07:45:02
I have the following mixin for cross-browser transform: .transform (...) { -webkit-transform: @arguments; /* Chrome, Opera 15+, Safari 3.1+ */ -moz-transform: @arguments; /* Firefox 3.5+ */ -ms-transform: @arguments; /* IE 9 */ -o-transform: @arguments; /* Opera 10.5+ */ transform: @arguments; /* Firefox 16+, IE 10+, Opera */ } .translate(@x:0, @y:0) { .transform(translate(@x, @y)); } And apply it something like the following: #main { .translate(280px, 0); } But it's not wotk in IE8 and Opera mini . Is there some fallback, polyfill or any for supporting it in therese browsers? There are a few

Convert px to em in Less

ε祈祈猫儿з 提交于 2019-11-30 07:44:38
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? 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; } Iggy van Lith With LESS you can build your own functions. I use this function with the grunt-contrib-less package. The formatting is slightly different from the usual

Is it possible to pass !important as parameter/option for LESSCSS mixins?

孤街醉人 提交于 2019-11-30 07:37:39
问题 This is what I already have: .coloring(@color){ color:@color; } But this is what I actually wanted to do: .coloring(@color, @important:''){ color:@color @important; //etc } So I could call: .coloring(@color, !important); But I get the error message "ParseError: Unrecognised input" Is there a way to tell this mixin optoinally to use "!important" for the CSS statements? 回答1: See The !important keyword. E.g. can just use .coloring(red) !important; w/o mixin changes. Or use escaping for the

LESS CSS: Reuse generated .@{name} class as a mixin

混江龙づ霸主 提交于 2019-11-30 07:25:11
I'm using LESS CSS 1.3.3. Sorry if this question has already been asked, I didn't find anything relevant on the web. I have several class generators that look like this (example extremely simplified, just enough to trigger the error): #genMarginTop (@name, @size) { .@{name} { margin-top: @size; } } Then I use them to generate some actual classes: #genMarginTop(mtStandard, 40px); #genMarginTop(mtHalf, 20px); So far, so good, LESS correctly generates those classes and I can use them in the HTML. However when I want to reuse such a generated class as a mixin somewhere else, I get an error:

How can I force assetic to render assets each time the page is reloaded?

时光怂恿深爱的人放手 提交于 2019-11-30 07:05:19
How can I force assetic to render assets each time the page is reloaded (no matter if assets are modified or not)? More explanation about my issue: I'm currently working on a Symfony2 project where I use Assetic to manage and compile .less files. I got everything to work fine but I'm having a small issue that I'd like to fix. In config.yml, I set the assetic use_controller to true. # Assetic Configuration assetic: debug: %kernel.debug% use_controller: true The result is that Symfony dynamically renders the new .css files each time .less files are modified. This is great. My problem is that I

Enable inline javascript in LESS

喜夏-厌秋 提交于 2019-11-30 06:40:31
I would like to use inline js in my less files but I get the following message: Inline JavaScript is not enabled. Is it set in your options? How can I enable that? I had same problem, I use webpack with less loader, I needed to add javascript option in less loader config: { test: /\.less$/, use: [{ loader: "style-loader" }, { loader: "css-loader" }, { loader: "less-loader", options: { javascriptEnabled: true } }] } I found in the sourcecode of less compiler: https://github.com/less/less.js/blob/3.x/bin/lessc that they parse js less option in this way: case 'js': options.javascriptEnabled =