CSS ไอคอน

วิธีเพิ่มอิコン

วิธีที่ง่ายที่สุดในการเพิ่มอิコンลงในหน้า HTML คือการใช้คลังอิコン อย่างเช่น Font Awesome

เพิ่มชื่อรูปแบบอิコンที่กำหนดไปยังอนุภาค HTML ภายในตาราง (เช่น <i> หรือ <span>)

ทั้งหมดอิコンในคลังอิコンดังกล่าวเป็นวัตถุประยุกต์ทางเลือกที่สามารถย่อยขยายได้ และสามารถปรับแต่งด้วย CSS (ขนาด、สี、เงาและอื่นๆ)

Font Awesome อิコン

หากต้องการใช้รูปภาพแสดง Font Awesome โปรดเข้าเว็บไซต์ fontawesome.com ล็อกอินและสร้างรหัสเพื่อเพิ่มเข้าไปในหัวเว็บ (head) ของ HTML ของคุณ:

<script src="https://kit.fontawesome.com/yourcode.js"></script>

อ่านเพิ่มเติมเกี่ยวกับวิธีการเริ่มใช้ Font Awesome ในคู่มือของเรา Font Awesome 5。

คำเตือน:ไม่ต้องดาวน์โหลดหรือติดตั้ง!

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>
<i class="fas fa-cloud"></i>
<i class="fas fa-heart"></i>
<i class="fas fa-car"></i>
<i class="fas fa-file"></i>
<i class="fas fa-bars"></i>
</body>
</html>

ผลลัพธ์:

ทดลองด้วยตัวเอง

รูปภาพแสดง Bootstrap

หากต้องการใช้รูปภาพแสดง Bootstrap glyphicons โปรดเพิ่มบรรทัดดังนี้ในหัวเว็บ (head) ของ HTML ของคุณ:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

คำเตือน:ไม่ต้องดาวน์โหลดหรือติดตั้ง!

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<i class="glyphicon glyphicon-cloud"></i>
<i class="glyphicon glyphicon-remove"></i>
<i class="glyphicon glyphicon-user"></i>
<i class="glyphicon glyphicon-envelope"></i>
<i class="glyphicon glyphicon-thumbs-up"></i>
</body>
</html>

ผลลัพธ์:

ทดลองด้วยตัวเอง

รูปภาพแสดง Google

หากต้องการใช้รูปภาพแสดง Google ในหัวเว็บ (head) ของหน้า HTML ของคุณ โปรดเพิ่มบรรทัดดังนี้:

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

คำเตือน:ไม่ต้องดาวน์โหลดหรือติดตั้ง!

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>
</body>
</html>

ผลลัพธ์:

ทดลองด้วยตัวเอง