ตัวอย่างเช่นถ้าฉันมี HTML ต่อไปนี้:
<div class="someDiv"></div>
และ CSS นี้:
.opacity {
filter:alpha(opacity=60);
-moz-opacity:0.6;
-khtml-opacity: 0.6;
opacity: 0.6;
}
.radius {
border-top-left-radius: 15px;
border-top-right-radius: 5px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
}
.someDiv {
background: #000; height: 50px; width: 200px;
/*** How can I reference the opacity and radius classes here
so this div has those generic rules applied to it as well ***/
}
เช่นเดียวกับวิธีการใช้ภาษาสคริปต์คุณมีฟังก์ชันทั่วไปที่มักใช้เขียนไว้ที่ด้านบนสุดของสคริปต์และทุกครั้งที่คุณต้องการใช้ฟังก์ชันนั้นคุณเพียงแค่เรียกใช้ฟังก์ชันนั้นแทนการใช้รหัสซ้ำทุกครั้ง