Search code examples
cssstylus

How to make the stylus more efficient


I have the following code and wish how I can do it in stylus

CSS

h1 {
    font-size: 36px
}
h2 {
    font-size: 32px
}
h3 {
    font-size: 28px
}
h4 {
    font-size: 24px
}
h5 {
    font-size: 20px
}
h6 {
    font-size: 16px
}

Stylus

for num in (1..6)
    h-{num}
        font-size 32px

First would be to loop in the heading and then nose as I would do another loop for the font-size


Solution

  • size= 36px 32px 28px 24px 20px 16px
    for num,$s in  size
        h{$s+1} num
    

    click here for demo