transform rotate
block. Secondly: recently I look at the web through the Retina display and the non-optimized img
immediately catch the eye, but developers also pay attention to some kind of ribbon, optimize its display with media queries, it seems to me even a little ridiculous.top
and -left
. What does not suit me this option? Firstly, perfectionism: I want the maximum number of specified pixels (in this case, 500) to be displayed in the workspace and not to go for it. Secondly - laziness: I don’t want to manually select values ​​in order to hide all angles when changing positions (top, right, bottom, left) and degrees of inclination. .MojoRibbon(@width, @height, @deg, @valign) { width: @width; height: @height; -webkit-box-sizing: border-box; /* padding */ -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; .defineDegree(@deg, @valign) when (@deg < 0) and (@valign = top) { @degree: -@deg; /* , sin */ top: @countHeight; left: @countWidth; -webkit-transform: rotate(@deg); -moz-transform: rotate(@deg); -o-transform: rotate(@deg); -ms-transform: rotate(@deg); transform: rotate(@deg); }; .defineDegree(@deg, @valign) when (@deg < 0) and (@valign = bottom) { @degree: -@deg; /* , sin */ bottom: @countHeight; right: @countWidth; /* , */ -webkit-transform: rotate(@deg); -moz-transform: rotate(@deg); -o-transform: rotate(@deg); -ms-transform: rotate(@deg); transform: rotate(@deg); }; .defineDegree(@deg, @valign) when (@deg > 0) and (@valign = top) { @degree: @deg; top: @countHeight; right: @countWidth; -webkit-transform: rotate(@degree); -moz-transform: rotate(@degree); -o-transform: rotate(@degree); -ms-transform: rotate(@degree); transform: rotate(@degree); }; .defineDegree(@deg, @valign) when (@deg > 0) and (@valign = bottom) { @degree: @deg; bottom: @countHeight; left: @countWidth; /* , */ -webkit-transform: rotate(@degree); -moz-transform: rotate(@degree); -o-transform: rotate(@degree); -ms-transform: rotate(@degree); transform: rotate(@degree); }; .defineDegree(@deg, @valign) when (@deg = 0) { @degree: @deg; top: 0; left: 0; }; .defineDegree(@deg, @valign); @angleB: 90-@degree; @angleB2: @angleB; @sideA: round(sin(@degree), 3)*@width; /* */ @sideB: round(sin(@angleB), 3)*@width; /* B */ @sideB2: round(sin(@angleB2), 3)*@height; /* 2 */ @sideA2: round(sin(@degree), 3)*@height; /* B2 */ @countHeight: @sideA/2 - @height/2 - @sideB2/2; @countWidth: -((@width)-(@sideB))/2 - @sideA2/2; }
Source: https://habr.com/ru/post/186386/
All Articles