I usually write SASS, but for a particular project I have to use LESS.
How do I achieve something like the below using less? Using sass the mixin can be called like @include align(hcenter top) to position an element horizontally in the middle and to the top.
@mixin align($styles) {
position: absolute;
content: '';
display: block;
@each $style in $styles {
@if ($style == center) {
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
@if ($style == hcenter) {
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
}
@if ($style == vcenter) {
margin-top: auto;
margin-bottom: auto;
top: 0;
bottom: 0;
}
@if ($style == top) {
top: 0;
}
@if ($style == bottom) {
bottom: 0;
}
@if ($style == right) {
right: 0;
}
@if ($style == left) {
left: 0;
}
}
}