【问题标题】:Carrierwave video uploader - Rails 4Carrierwave 视频上传器 - Rails 4
【发布时间】:2015-07-05 06:29:05
【问题描述】:

我在 Rails 4 应用中使用carrierwave。

我正在尝试将视频上传到我的应用,然后在我创建的容器 div 中显示它们,并显示控件。

我有一个名为 video_uploader.rb 的上传文件:

storage: file
 def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

在我的 projects.rb 中,我有:

  mount_uploader :link_to_video_proposal, VideoUploader

在我的项目展示中,我有:

<div class="embed-container1">
          <%= video_tag @project.link_to_video_proposal_url :controls =>true %>
</div>

在我的项目 css 文件中,我将 embed-container1 定义为:

.embed-container1 {
  position: relative;
  padding-bottom: 56.25%;
  padding-top: 30px;
  height: 50px;
  width: 200px;
  overflow: hidden;
  //width: 80%;
  //padding-left: 5%;
  //padding-right:5%;
  margin-bottom: 12px;
  margin-top:12px;
}

.embed-container1 iframe,
.embed-container1 object,
.embed-container1 embed {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;

}

当我在 google 中检查元素时,代码周围似乎还有一个 css div。该 div 称为视频。我没有定义它,它不在我的代码中。它有一行 CSS 指定:

video {
  object-fit: contain;
}

我不知道这是否是导致我的问题的原因。当我运行页面时 - 我遇到了这些问题:

  1. 控件未出现在视频中。现在有没有人为什么不呢?我在我的显示页面中指定 :controls => true。

  2. embed-container1 的框大小为 50 像素 x 200 像素。但是,在 google 中检查视频 div(我没有创建或调用的 div)指定 1920*1080 的大小。

  3. embed-container1 的 div 大小在 google 检查器中显示为 200 * 229px。我指定了 50*200。视频没有填满那个框,也没有使用我的 CSS。

有谁知道如何使用 Carrierwave 上传承认项目中定义的 CSS 的视频?我看不出如何修复这组错误。

谢谢

【问题讨论】:

    标签: css ruby-on-rails carrierwave


    【解决方案1】:

    您需要将您的 css 设置为:

    .embed-container1 video{}
    

    并开始使用适合您要求的样式:)

    (在 Firefox 和 Chrome 上测试)

    【讨论】:

      猜你喜欢
      • 2015-06-10
      • 2016-04-05
      • 2016-12-22
      • 2013-11-20
      • 1970-01-01
      • 2017-03-02
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      相关资源
      最近更新 更多