CSS klasių grupavimas
Tarkime, kad turime keletą klasių, kurios dažo elementus į skirtingas spalvas:
.xxx {
color: green;
}
.yyy {
color: red;
}
Tarkime, kad norime padaryti taip, kad šios klasės be spalvos, nustatytų ir šrifto dydį:
.xxx {
color: green;
font-size: 30px;
}
.yyy {
color: red;
font-size: 30px;
}
Kad abi klasės nustato vienodą šrifto dydį, panaudokime selektorių grupavimą taip:
.xxx {
color: green;
}
.yyy {
color: red;
}
.xxx, .yyy {
font-size: 30px;
}
Supaprastinkite kodą, naudodami selektorių grupavimą:
.eee {
font-size: 20px;
line-height: 1.5;
font-family: Arial;
}
.zzz {
font-size: 30px;
line-height: 1.5;
font-family: Arial;
}
Supaprastinkite kodą, naudodami selektorių grupavimą:
.eee {
font-size: 20px;
text-align: center;
font-family: Arial;
}
.zzz {
font-size: 30px;
text-align: center;
font-family: Arial;
}
.ggg {
font-size: 35px;
text-align: center;
font-family: Arial;
}