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

相关推荐
前端架构师-老李6 小时前
HTML与CSS基础第四课—strong、em、b、i 各表示什么
前端·css·html
reasonsummer8 小时前
【教学类-07-12】20261028大3班破译电话号码html(手机按钮版本)
python·html
砚凝霜9 小时前
CTF Misc 签到 GXUST·CTF:查看源码 + HTML 注释 + Base64 解码(附 Base64 原理)
前端·html
夜雪一千1 天前
标题特殊符号数据清洗实战:解决HTML实体、零宽字符、Emoji乱码踩坑
前端·html
前端架构师-老李1 天前
HTML与CSS基础第二课—初识HTML
前端·css·html
CappuccinoRose1 天前
拖拽交互体系
前端·javascript·css·html·交互·1024程序员节
এ慕ོ冬℘゜2 天前
如何在 HTML 中嵌入音频和视频?
前端·html·音视频
sycmancia2 天前
Qml——Text元素
java·前端·html
西凉的悲伤2 天前
Jsoup 库 HTML 解析详解
java·前端·html·jsoup
inksci3 天前
在线编辑表格,功能强大,json互转
前端·javascript·html