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

相关推荐
HetFrame2 小时前
一种纯前端实现 Markdown 内容即时分享的思路
html·react·链接·markdown·工具
GGGG寄了2 小时前
CSS——文字控制属性
前端·javascript·css·html
浩瀚之水_csdn3 小时前
vscode中运行html语言
ide·vscode·html
HWL56793 小时前
在网页中实现WebM格式视频自动循环播放
前端·css·html·excel·音视频
薛定谔的猫喵喵3 小时前
猪笼草生长环境模拟器:交互式生物教育工具实现指南
python·html·echarts·js
雯0609~14 小时前
hiprint:实现项目部署与打印1-官网提供普通html版本
前端·html
编程之升级打怪1 天前
网页端即时通信应用消息列表的更新逻辑
html·信息与通信
会编程的土豆1 天前
简易植物大战僵尸游戏 JavaScript版之html
javascript·游戏·html
GGGG寄了1 天前
CSS——CSS引入方式+选择器类型
前端·css·html
qq_12498707531 天前
基于html的书城阅读器系统的设计与实现(源码+论文+部署+安装)
前端·vue.js·spring boot·后端·mysql·信息可视化·html