Less (Leaner Style Sheets)
Less เป็นพรีโปรเซสเซอร์ CSS ที่เพิ่มตัวแปร mixins การซ้อน และฟังก์ชันให้กับ CSS มาตรฐาน ไฟล์ Less คอมไพล์เป็น CSS ปกติทั้งฝั่งเซิร์ฟเวอร์หรือในเบราว์เซอร์
ประเภท MIME
text/x-less
ประเภท
ข้อความ
การบีบอัด
ไม่สูญเสียคุณภาพ
ข้อดี
- + Variables and mixins reduce CSS repetition
- + Can compile in the browser without a build step
- + Simpler syntax than early Sass (no indentation rules)
ข้อเสีย
- − Declining ecosystem — Sass is more widely used
- − Native CSS custom properties replace many Less features
- − Fewer functions and features than modern Sass
เมื่อใดควรใช้ .LESS
ใช้ Less สำหรับโปรเจกต์ที่ใช้อยู่แล้ว; สำหรับโปรเจกต์ใหม่ แนะนำ Sass หรือ CSS custom properties ดั้งเดิม
รายละเอียดทางเทคนิค
Less ขยาย CSS ด้วย @variables คำจำกัดความ .mixin() การซ้อน และฟังก์ชันในตัวสำหรับการจัดการสีและคณิตศาสตร์ คอมไพล์ผ่าน Node.js (lessc) หรือในเบราว์เซอร์ด้วย less.js
ประวัติ
Alexis Sellier สร้าง Less ในปี 2009 เป็นทางเลือกที่ง่ายกว่า Sass Bootstrap 3 (2013) ใช้ Less เป็นพรีโปรเซสเซอร์เริ่มต้น แต่ Bootstrap 4 เปลี่ยนเป็น Sass ในปี 2018