简体   繁体   English

@media(最大宽度或最小宽度)用于视频

[英]@media (max-width or min-width) for video

I want to ask - this function for an image to hide or reveal at a given resolution (sample in code) - can it be applied to video as well ?我想问 - 这个 function 用于在给定分辨率下隐藏或显示图像(代码示例) -它也可以应用于视频吗? Thanks谢谢

 @media (max-width:375px) { img#eq { display: none; }
 <img id="eq" src="assets/images/picture.jpg">

Media Queries can be used always within CSS and works on everything that can eb addressed by CSS. Media Queries始终可以在 CSS 中使用,并且适用于 CSS 可以解决的所有问题。 This also includes videos as the snippet below shows.这还包括以下片段所示的视频。

 video { width: 100%; } @media only screen and (max-width: 374px) { video { display: none; } } @media only screen and (min-width: 375px) { video { display: block; } }
 <video controls> <source src="https://www.tacoshy.de/stackoverflow/testvideo.mp4" type="video/mp4"> Your browser does not support the video tag. </video>

yes it will work and first you want to add a meta tag in your html head it is look like是的,它会起作用,首先你想在你的 html 头中添加一个元标记,它看起来像

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM