我在视频文件中设置了couple_walk.mp4并在下面编写了代码来上传它,但根本不起作用。我想在标题上显示视频。
<div class = "header-container">
<div class = "video-container">
<video preload = "true" autoplay = "autoplay" loop = "loop" volume = "0" poster = "pic.jpg">
<source src=<%= video_tag("couple_walk.mp4") %> type = "video/mp4" >
</video>
</header>
以上的css代码低于
.header-container {
width: 100%;
height: 900px;
border-left: none;
border-right: none;
position: relative;
padding: 20px;
}
.video-container {
position: absolute;
top: 0%;
left: 0%;
height: 100%;
width: 100%;
overflow: hidden;
}
video {
position: absolute;
z-index: -1;
opacity: 0.78;
width: 100%;
}
任何想法?
答案 0 :(得分:0)
替换
<video preload = "true" autoplay = "autoplay" loop = "loop" volume = "0" poster = "pic.jpg">
<source src=<%= video_tag("couple_walk.mp4") %> type = "video/mp4" >
</video>
与
<%= video_tag("couple_walk.mp4", controls: true, autobuffer: true, poster: "pic.jpg")
会产生
<video src="/videos/couple_walk.mp4", controls: true, autobuffer: true, poster="/assets/screenshot.png"></video>
参考:http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html