How to add javascript expression's output to my CSS?


Tags: javascript,css,less

Problem :

Is there any way to throw a javascript expression's output (which is a series of classes) into the CSS generated by LESS? For example, i want to output:

.grid_1 { .grd(1); } .grid_2 { .grd(2); } .grid_3 { .grd(3); } .grid_4 { .grd(4); } .grid_5 { .grd(5); } .grid_6 { .grd(6); } .grid_7 { .grd(7); } .grid_8 { .grd(8); } .grid_9 { .grd(9); } .grid_10 { .grd(10); } .grid_11 { .grd(11); } .grid_12 { .grd(12); }

......by including this code in LESS:

`(function(b){var a="";for(i=1;i<b;i++)a+=".grid_"+i+" { .grd("+i+"); }\n";return a})(12)`;


Solution :

I do not think this is possible with LESS. The extent of the JavaScript evaluation appears to just work for variables and CSS properties.


    CSS Howto..

    How to locate a list of webelement using Css selector in C#

    How can I style jQuery-UI autocomplete differently than jQuery-UI tabs?

    How to use Google Libraries API (jQuery) with Google App Engine?

    How to manipulate the CSS at runtime

    How do I get a div to be positioned above an image?

    How to conditionally add css properties in jquery (coffeescript)

    How to apply the grayscale jquery plugin to a background image?

    How do I increase the width of a navbar dropdown?

    How would I do a two finger drag with javascript/jquery?

    How to add Bootstrap to Fullpage.js

    css: how to make
    not highlighted when selecting text (in Chrome)

    How to make common reusable css for almost every common things in web design?

    Position: fixed Background DIV with images makes scrolling slow: How to make conditional CSS rules for browser-compatibility?

    How to create circle, square or triangle with JavaScript in HTML?

    Keep mobile browser from showing elements outside body?

    how to locate an element by value using css selector in webdriver?

    How to select multiple items using mouse click?

    How can I get two form fields side-by-side, with each legend above the field?

    How to click an element by innerthtml using CSS selectors in Selenium

    Bootstrap How to make a responsive grid degradating in two steps?

    How to use CSS grid framework for custom widths and gutters?

    How to make footer not overlap and positioned properly?

    jQuery beginner: how to add css transition when using toggleClass(“open”)?

    How to add css in php file? [closed]

    How to select css id's with numbers in them?

    How can I display these images with CSS instead of HTML?

    How to eliminate scroll text jumps

    IBM Worklight - How to disable Native device features?

    How to add an anchor tag to a block of html?

    How would you code this: The SO Menu [closed]