Sometimes it's need to center block only vertically or horizontally. Maybe it's worth to replace center with more general align( [vertical], [horizontal] ). vertical argument can be one of top, center, bottom and horizontal argument can be one of left, center, right:
/* before */
.centered {
@util align(center, center);
}
.aligned {
@util align(bottom, right);
}
/* after */
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.aligned {
position: absolute;
bottom: 0;
right: 0;
}
Also It may be useful to have fill values for both arguments:
/* before */
.fill-horizontally {
@util align(center, fill);
}
/* after */
.fill-horizontally {
position: absolute;
top: 50%;
left: 0;
rigth: 0;
transform: translateY(-50%);
}
All this behaviour can be implemented with flexbox method too
Sometimes it's need to center block only vertically or horizontally. Maybe it's worth to replace
centerwith more generalalign( [vertical], [horizontal] ).verticalargument can be one oftop,center,bottomandhorizontalargument can be one ofleft,center,right:Also It may be useful to have
fillvalues for both arguments:All this behaviour can be implemented with
flexboxmethod too