视频背景大小调整问题

时间:2015-12-08 21:32:59

标签: jquery html css video

我在我的网站背景中播放视频,但我无法正确调整大小。如果我让它适合整个页面的高度,它会拉伸宽度并在右侧添加一个水平滚动条到多余的部分。但是,如果我正确地调整宽度,则视频会在页面的中间结束。

<div class="object fullbleed" style="width: auto; height: auto; position: absolute; left: 0px; top: 0px; border-style: none; border-color: rgba(0, 0, 0, 0); transform: translateX(-50%); min-width: 100%; box-sizing: border-box; background-color: rgba(0, 0, 0, 0);" id="pink-ink-spread" data-alt-style="width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; border-style: none; border-color: rgba(0, 0, 0, 0); background-color: rgba(0, 0, 0, 0);" data-alt-hidden="true">
<script type="disabled" data-runtime-script="true">$(document).ready(function()
{
    var element = $('#pink-ink-spread');
    var videoLink = 'https://siteassets.pagecloud.com/remarkableresults/downloads/Red_wine_falling_1080p_(Video_Only)-ID-c0fd8d89-0612-4fb1-ddb1-c8887092b627-ID-d71bad33-71ac-4084-e4d1-a0303eb71c8a.mp4';
    var videoElement = '<video id="pink-ink" poster="https://personalpageassets.pagecloud.com/nick-belland1/images/transparent-ID-3ceacd26-d065-45ee-b413-694a7ba42234.png?nocache=7fb20c9a-a6b9-4fa4-afac-155eb904dc0c"><source src="'+videoLink+'" type="video/mp4"></video>';

    element.append(videoElement);

    var pinkInk = $('#pink-ink').css({
    'position':'absolute',
    'right':0,
    'width':'auto',
    'height':'auto',
    'background-color':'#fff',
    'display':'none'
});

pinkInk.show().get(0).play();

element.click(function(e)
{

});

element.mouseenter(function(e)
{

});

element.mouseleave(function(e)
{

});

element.on('scrollin', function(e)
{

});

element.on('scrollout', function(e)
{

});
});</script>
    <video id="pink-ink" poster="https://personalpageassets.pagecloud.com/nick-belland1/images/transparent-ID-3ceacd26-d065-45ee-b413-694a7ba42234.png?nocache=7fb20c9a-a6b9-4fa4-afac-155eb904dc0c" style="position: absolute; right: 0px; width: auto; background-color: rgb(0, 0, 0);"><source src="https://siteassets.pagecloud.com/remarkableresults/downloads/Red_wine_falling_1080p_(Video_Only)-ID-c0fd8d89-0612-4fb1-ddb1-c8887092b627-ID-d71bad33-71ac-4084-e4d1-a0303eb71c8a.mp4" type="video/mp4"></video>

我不确定我是否可以使用代码修复它,或者我是否必须以某种方式重新调整视频尺寸以使其正常工作。

1 个答案:

答案 0 :(得分:0)

您是否尝试过设置css宽度和高度属性。

&#13;
&#13;
body,html {
  width:100%;
  height:100%;
}

video {
  width:100%;
  height:100%;
}
&#13;
&#13;
&#13; https://jsfiddle.net/0t3jefz1/