为什么内联视频 src 媒体查询不起作用?
How come inline video src media queries aren't working?
我最近创建的网页有两个视频,但内联媒体查询不起作用。
播放器正在拉取源列表中的第一个视频。
这是我的代码:
<video class="intro-video" controls poster="lineandgrid-video-intro-cover.gif">
<source media="(max-width: 750px)" src="lineandgrid-introduction-video-mobile.mp4" type="video/mp4">
<source media="(min-width: 751px)" src="lineandgrid-introduction-video.mp4" type="video/mp4">
</video>
有人可以告诉我我做错了什么吗?您可以在此处查看实时网页:https://lineandgrid.ca/video/
媒体查询通常只支持 元素。
Attributes: Media:
Media query of the resource's intended media; this should be used only in a <picture> element.
来源:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source:
Chrome does not support inline media queries on the source tag within
videotag. [...] Worse, plain media queries will not stop multiple
videos from loading, which effectively doubles your data, so it
requires a JS solution.
建议的JS解决方案,如果原博客post变得不可用:https://gist.githubusercontent.com/fuzzywalrus/8abdd088e3fb6a73fd5d980f7bab0118/raw/9922cce9c4c040164f383671070e588c2adff944/responsivevideo.js
原回答:
Apparently, support for inline media queries has been removed:
Chrome not respecting video source inline media queries
我最近创建的网页有两个视频,但内联媒体查询不起作用。
播放器正在拉取源列表中的第一个视频。
这是我的代码:
<video class="intro-video" controls poster="lineandgrid-video-intro-cover.gif">
<source media="(max-width: 750px)" src="lineandgrid-introduction-video-mobile.mp4" type="video/mp4">
<source media="(min-width: 751px)" src="lineandgrid-introduction-video.mp4" type="video/mp4">
</video>
有人可以告诉我我做错了什么吗?您可以在此处查看实时网页:https://lineandgrid.ca/video/
媒体查询通常只支持
Attributes: Media: Media query of the resource's intended media; this should be used only in a <picture> element.
来源:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source:
Chrome does not support inline media queries on the source tag within videotag. [...] Worse, plain media queries will not stop multiple videos from loading, which effectively doubles your data, so it requires a JS solution.
建议的JS解决方案,如果原博客post变得不可用:https://gist.githubusercontent.com/fuzzywalrus/8abdd088e3fb6a73fd5d980f7bab0118/raw/9922cce9c4c040164f383671070e588c2adff944/responsivevideo.js
原回答:
Apparently, support for inline media queries has been removed:
Chrome not respecting video source inline media queries