30 likes | 167 Vues
Explore the power of LESS variables and mixins to streamline your CSS. In this guide, learn to implement color variables like `@color: #4D926F` for consistent theming and apply dynamic styles. Discover how to create reusable mixins for rounded corners with customizable radii for headers and footers, resulting in clean and maintainable code. This approach ensures a modern edge to your web design while optimizing CSS for cross-browser compatibility. Elevate your front-end development skills with efficient styling techniques.
E N D
LESS - Variables Mixins
Variables // Less @color: #4D926F; #header { color:@color; } h2 { color: @color; } • // css @color: #4D926F; #header { • color:#4D926F; } h2 { • color: #4D926F; }
Mixins /* Compiled CSS */ #header { -webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; -o-border-radius:5px; border-radius:5px; } #footer { -webkit-border-radius: 10px; -moz-border-radius: 10px;-ms-border-radius:10px; -o-border-radius: 10px; border-radius:10px; } // LESS .rounded-corners (@radius: 5px) { -webkit-border-radius:@radius; -moz-border-radius: @radius; -ms-border-radius: @radius; -o-border-radius: @radius; border-radius:@radius; } #header { .rounded-corners; } #footer { .rounded-corners(10px); }