Grupimi i Klasave në CSS
Le të supozojmë se kemi disa klasa që i ngjyrosin elementet në ngjyra të ndryshme:
.xxx {
color: green;
}
.yyy {
color: red;
}
Le të supozojmë se duam që këto klasa, përveç ngjyrës, të vendosin gjithashtu madhësinë e shkronjave:
.xxx {
color: green;
font-size: 30px;
}
.yyy {
color: red;
font-size: 30px;
}
Meqenëse të dyja klasat vendosin të njëjtën madhësi shkronjash, le të përdorim grupimin e selektorëve në mënyrën e mëposhtme:
.xxx {
color: green;
}
.yyy {
color: red;
}
.xxx, .yyy {
font-size: 30px;
}
Thjeshtoni kodin, duke përdorur grupimin e selektorëve:
.eee {
font-size: 20px;
line-height: 1.5;
font-family: Arial;
}
.zzz {
font-size: 30px;
line-height: 1.5;
font-family: Arial;
}
Thjeshtoni kodin, duke përdorur grupimin e selektorëve:
.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;
}