如何在HTML中指定在不同情况下使用的图像的URL?
使用 srcset 属性指定要在 HTML 中的不同情况下使用的图像的 URL。
示例 h2>
您可以尝试运行以下代码来实现srcset属性。调整浏览器大小以查看加载的不同图像 –
<!DOCTYPE html>
<html>
<head>
<meta name = viewport content=width=device-width, initial-scale = 1.0>
</head>
<body>
<picture>
<source media = (min-width: 550px) srcset = https://www.tutorialspoint.com/assets/videotutorials/courses/3d_animation_online_training/380_course_211_image.jpg>
<source media = (min-width: 400px) srcset = https://www.tutorialspoint.com/assets/videotutorials/courses/html_online_training/380_course_216_image.jpg>
<img src = https://www.tutorialspoint.com/videotutorials/images/tutorial_library_home.jpg alt = Tutorials Library style = width:auto;>
</picture>
</body>
</html>
以上就是如何在HTML中指定在不同情况下使用的图像的URL?的详细内容,更多请关注双恒网络其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。



