使用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>

相关推荐
胡gh1 小时前
css的臂膀,前端动效的利器,还是布局的“隐形陷阱”?
前端·css·html
十一.3664 小时前
103-105 添加删除记录
前端·javascript·html
大怪v11 小时前
【Virtual World 005】上帝之眼
前端·javascript·html
0思必得011 小时前
[Web自动化] HTML元素及DOM元素
前端·python·自动化·html·web自动化
Mintopia12 小时前
🤖 当人工智能开始“写”前端:一场硅基的艺术创作
人工智能·llm·html
weixin_3077791313 小时前
Jenkins jsoup API 插件:强大的 HTML 解析底层支持与使用指南
运维·前端·架构·html·jenkins
0思必得013 小时前
[Web自动化] HTML元素的定位(Xpath)
前端·python·自动化·html·web自动化
m5655bj13 小时前
如何通过 C# 实现 Markdown 转 HTML 格式
开发语言·c#·html
码银14 小时前
3D动态圣诞树代码
3d·html
威哥爱编程1 天前
屌炸天!一句话搞定一个商用级的商城列表页面
html·ai编程·trae