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

相关推荐
放飞自我的Coder7 小时前
【Mermaid本地实时渲染 单html本地直接运行】
html·mermaid
共享家95277 小时前
打造AI智能”成语接龙“游戏
前端·javascript·人工智能·python·游戏·html
AAA阿giao7 小时前
HTML5模块化开发:结构、样式与交互分离
前端·html·html5
顾西爵霞8 小时前
HTML 零基础入门:像搭积木一样建网页
前端·html
顾西爵霞9 小时前
HTML 进阶:给房子装窗户、通道和前台系统
前端·javascript·html
weixin_456907411 天前
2026+:html+css 生态的成型之年与平台化跃迁
前端·css·html
weixin_456907411 天前
【html+Tss 故障排查】链20230304 最详细解析之像素已拉取,容器仍起不来(含命令清单)
前端·html
Zhu_S W1 天前
基于Java和Redis实现排行榜功能
前端·bootstrap·html
Eiceblue1 天前
通过 C# 解析 HTML:文本提取 + 结构化数据获取
c#·html·.net·visual studio
weixin_456907411 天前
使用 html为 ppt 文档添加文本像素格的实用方法
html·tensorflow·powerpoint