HTML <source> srcsetแอตทริบิวต์
ตัวอย่าง
อิลิเมนต์ <picture> ที่มีไฟล์ต้นฉบับ 2 ไฟล์ และอิมเมจสำรอง:
<picture>
<source media="(min-width:650px)" srcset="img_pink_flowers.jpg">
<source media="(min-width:465px)" srcset="img_white_flower.jpg">
<img
src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
</picture>
ความหมายและการใช้งาน
แอตทริบิวต์srcset
ระบุ URL ของรูปภาพเพื่อใช้ในสถานการณ์ต่างๆ
แอตทริบิวต์นี้จำเป็นเมื่อ<source>
ถูกใช้ใน
<picture>
.
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนแอตทริบิวต์อย่างเต็มที่
Attribute | |||||
---|---|---|---|---|---|
srcset | 38.0 | 13.0 | 38.0 | 9.1 | 25.0 |
ไวยากรณ์
<source srcset="URL">
ค่าแอตทริบิวต์
Value | Description |
---|---|
URL | Specifies the URL of the image. Possible values:
|
❮ แท็ก HTML <source>