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

相关推荐
tod11317 小时前
Redis 数据类型与 C++ 客户端实践指南(redis-plus-plus)
前端·c++·redis·bootstrap·html
henry10101021 小时前
Deepseek辅助生成的HTML5网页版抄经典《弟子规》
前端·javascript·css·html·html5
想睡好1 天前
标签的ref属性
前端·javascript·html
henry1010101 天前
HTML5小游戏 - 数字消除 · 合并2048
前端·游戏·html·html5
杨超越luckly1 天前
HTML应用指南:利用GET请求获取中国邮政网点位置信息
前端·python·arcgis·html·php·数据可视化
Go_Zezhou1 天前
render网站保存历史记录错误解决
开发语言·git·python·html
CappuccinoRose1 天前
HTML语法学习文档(三)
前端·学习·html·html5·标签·实体字符
小九今天不码代码1 天前
HTML + CSS 实现鼠标悬停触发的全景动画效果
html·css动画·网页特效·前端交互·纯css效果·鼠标悬停动画·全景滑动效果
星火开发设计2 天前
类模板:实现通用数据结构的基础
java·开发语言·数据结构·c++·html·知识
卷卷的小趴菜学编程2 天前
项目篇----仿tcmalloc的内存池设计(内存回收)
前端·后端·html·tcmalloc·内存池