ckplayer所在的div容器以直接设置宽度和高度为多少px的方式才能正确设置其宽度和高度
1.html部分
<div id="video-div">
<div class="video" id="video-player"
style="width: 100%; height: 720px;max-width: 1280px; max-height: 720px;">播放容器</div>
</div>
2.js部分
function windowResize() {
// 获取id="video-div"的容器的宽度
var bodyWidth = $("#video-div").width();
// 计算宽度和高度的新值 宽高比16:9
var newHeight = Math.round(bodyWidth * (9 / 16));
// 设置id="video-player"元素的宽度和高度
$("#video-player").css({
"width": "100%",
"max-width": "1280px",
"height": newHeight + "px",
"max-height": "720px"
});
}
3.body添加
<body οnresize="windowResize()">