Group multiple media queries formed as output of LESS css
- by Goje87
I was planning to use LESS css in my project (PHP). I am planning to use its nested @media query feature. I find that it fails to group the multiple media queries in the output css it generates.
For example:
// LESS
.header {
@media all and (min-width: 240px) and (max-width: 319px) {
font-size: 12px;
}
@media all and (min-width: 320px) and (max-width: 479px) {
font-size: 16px;
font-weight: bold;
}
}
.body {
@media all and (min-width: 240px) and (max-width: 319px) {
font-size: 10px;
}
@media all and (min-width: 320px) and (max-width: 479px) {
font-size: 12px;
}
}
// output CSS
@media all and (min-width: 240px) and (max-width: 319px) {
.header {
font-size: 12px;
}
}
@media all and (min-width: 320px) and (max-width: 479px) {
.header {
font-size: 16px;
font-weight: bold;
}
}
@media all and (min-width: 240px) and (max-width: 319px) {
.body {
font-size: 10px;
}
}
@media all and (min-width: 320px) and (max-width: 479px) {
.body {
font-size: 12px;
}
}
My expected output is (@media queries grouped)
@media all and (min-width: 240px) and (max-width: 319px) {
.header {
font-size: 12px;
}
.body {
font-size: 10px;
}
}
@media all and (min-width: 320px) and (max-width: 479px) {
.header {
font-size: 16px;
font-weight: bold;
}
.body {
font-size: 12px;
}
}
I would like to know if it can be done in LESS it self or is there any simple CSS parser I can use to manipulate the output CSS to group the @media queries.