Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

วิธีสร้าง Typography แบบ Responsive ด้วย CSS


ในการสร้าง Typography ที่ตอบสนองตามขนาดหน้าจอ (Responsive Typography) ด้วย CSS โค้ดมีดังนี้ −

ตัวอย่าง

<!DOCTYPE html> <html> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <head> <style>    h1 {       font-size: 10vw;    }    p {       font-size: 5vw;    } </style> </head> <body> <h1>Responsive Text Example</h1> <p> Lorem ipsum dolor sit amet consectetur, adipisicing elit. Earum, rerum. </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Excepturi, necessitatibus officiis hic est in nobis! </p> </body> </html>

ผลลัพธ์

โค้ดด้านบนจะแสดงผลดังนี้ −

วิธีสร้าง Typography แบบ Responsive ด้วย CSS

เมื่อปรับขนาดหน้าจอ −

วิธีสร้าง Typography แบบ Responsive ด้วย CSS