欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > 使用transform对html的video播放器窗口放大

使用transform对html的video播放器窗口放大

2024/10/24 21:33:13 来源:https://blog.csdn.net/xcg340123/article/details/142065413  浏览:    关键词:使用transform对html的video播放器窗口放大

核心是使用

<div class="video" style="width: 100%; height:700px;">播放容器</div>$('video').css({'transform': 'scale(2)','transform-origin': 'center top'});

其中

scale 表示放大倍数,可以是小数

transform-origin 表示位置,

1)可以使用坐标点 如 '120px 200px'

2)或者使用方位坐标,left right top bottom总共九个 ,如

左上方 'left top' 

上方 ‘top center’

右上方 'right top'

左方 'left center'

中间 'center center'

右方 'right center'

左下方 'right bottom'

下方 'bottom center'

右下方 'right bottom'

以下是html示例代码

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Video Scaling and Positioning</title>
  <style>
    .video-container {
      position: relative;
      width: 100%;  /* 容器宽度 */
      height: 100vh; /* 容器高度 */
      overflow: hidden; /* 超出部分隐藏 */
    }

    video {
      position: absolute;
      top: 50%;   /* 垂直居中 */
      left: 50%;  /* 水平居中 */
      transform: translate(-50%, -50%) scale(1); /* 初始缩放为1,居中 */
      transition: transform 0.5s ease; /* 增加缩放时的平滑过渡效果 */
    }

    /* 当鼠标悬停时,缩放并调整位置 */
    video:hover {
      transform: translate(-30%, -30%) scale(1.5); /* 缩放到1.5倍并移动位置 */
    }
  </style>
</head>
<body>
  <div class="video-container">
    <video src="video.mp4" controls></video>
  </div>
</body>
</html>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com