ใช้ border-radius สร้างรูปภาพมุมมน (Rounded) หรือวงกลม (Circular) ได้ตามต้องการ
ตัวอย่างโค้ด
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> img { border-radius: 50%; width: 300px; height: 300px; } </style> </head> <body> <h1>Rounded Images Example</h1> <img src="https://i.picsum.photos/id/271/400/400.jpg"> </body> </html>
Border-radius Values
| ค่า | ผลลัพธ์ |
|---|---|
0 | มุมฉาก (Default) |
4px - 12px | มุมมนเล็กน้อย (Card, Button) |
50% | วงกลม (ต้อง width=height) |
50% / 50% | Ellipse (วงรี) ถ้า width≠height |
25% 50% 75% 100% | มุมแต่ละมุมต่างกัน (TL, TR, BR, BL) |