CSS authoring guides

Compile an imported Less card theme into a CSS stylesheet

·

A reusable card can take its border and spacing from an imported theme. Compile both pieces together to check the exact CSS that will reach the browser.

Less to CSS

Compile the card with its theme file

Load the example and select Compile CSS. The main source imports theme.less. The inline theme defines @accent as #36826b and @space as 6px.

The .frame mixin produces a 2px solid #36826b border for .field-card. The nested direct-child caption rule has 12px padding because the source doubles the spacing variable.

Less language features including variables, mixins and imports

Restore a missing inline import

Rename the inline file while leaving the main import unchanged and compile again. The compiler identifies the unresolved import. Return the filename to theme.less to restore the result.

Use this check when reproducing a project stylesheet. Collect the Less files the entry point imports and give each supplied file the name used by the import.

Less language features including variables, mixins and imports

Compare and save the compiled CSS

Choose Compressed in Output style and compile again. The property values stay the same and formatting becomes compact.

Download CSS and reopen compiled-less.css. Check the card border and its child selector before using it alongside your page markup.

Less language features including variables, mixins and imports

Common questions

Why does the nested caption expand to a child selector?

The ampersand refers to the enclosing selector. The following greater-than token connects it to a direct child.

Where should I look after a compiler error?

Read the named source, line and column in the compiler diagnostic. An import can point to an inline file instead of the main editor.

Sources

Put it into practice.

Related guides