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

相关推荐
东方翱翔1 小时前
HTML中的文字与分区标记
java·前端·html
建群新人小猿5 小时前
CRMEB Pro版 DIY功能玩法即将升级,先来一睹为快!
前端·javascript·html
Dovir多多8 小时前
渗透测试入门学习——php与mysql数据库连接、使用session完成简单的用户注册、登录
前端·数据库·后端·mysql·安全·html·php
小刘|9 小时前
《实现 HTML 图片轮播效果》
前端·html
qq_4243171811 小时前
html+css+js网页设计 旅游 大理旅游7个页面
css·html·旅游
敲代码不忘补水14 小时前
二十种编程语言庆祝中秋节
java·javascript·python·golang·html
吕永强14 小时前
HTML表单标签
前端·html·表单标签
Smart-Space15 小时前
HtmlRender - c++实现的html生成类
c++·html
Passion不晚1 天前
制作炫酷个人网页:用 HTML 和 CSS3 展现你的风格
前端·html·css3
空欢ོ喜ꦿ℘゜1 天前
制作论坛帖子页面
前端·javascript·html·jquery