html
body
.flag
.saffron
.white
.wheel
.wheel-center
- var n = 24
while n --> 0
.spoke
.green
View Compiled
// navy blue
@blue: #000080;
// india saffron
@saffron: #ff9933;
// india green
@green: #138808;
// pure white
@white: #ffffff;
* {
box-sizing: border-box;
}
// mixin to center children using flex
// The parentheses at the end are optional, because the mixin does not
// take any arguments. But it's a good practice to use the parentheses
// always, so that we can tell at a glance that this is a mixin and not
// a class.
.center-elements () {
display: flex;
align-items: center;
justify-content: center;
}
body {
background: #1d1e22;
width: 100%;
height: 100vh;
.center-elements();
}
.flag {
width: 675px;
height: 450px;
}
.saffron, .white, .green {
width: 100%;
height: 150px;
}
.saffron {
background: @saffron;
}
.green {
background: @green;
}
.white {
background: @white;
padding: 15px;
.center-elements();
}
.wheel {
position: relative;
width: 120px;
height: 120px;
border-radius: 50%;
border: 4px @blue solid;
overflow: hidden;
.center-elements();
}
.wheel-center {
width: 20px;
height: 20px;
border-radius: 50%;
background: @blue;
}
.spoke {
position: absolute;
left: 56px;
top: 56px;
width: 31px;
height: 4px;
background: @blue;
transform-origin: 0 0;
&:after {
content: ' ';
position: absolute;
top: 2px;
left: -25px;
display: block;
width: 12px;
height: 12px;
border-radius: 50%;
background: @blue;
transform: skew(-84deg)translate(1px,3px);
}
}
// recursive mixin to generate the nth-of-type rulesets for spokes
// terminate when the value of @n reaches 26
.gen-spokes (@n) when (@n = 26) {}
// when value of @n is less than 26, generate the ruleset for the nth
// spoke and then apply self with the next value (@n + 1)
.gen-spokes (@n) when (@n < 26) {
@selector: ~".spoke:nth-of-type(@{n})";
@{selector} {
transform: rotateZ(@n * 15deg)skew(84deg);
}
@next: (@n+1);
.gen-spokes(@next);
}
.gen-spokes(1);
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.