2

我使用引导缩略图。但我想添加视频元素而不是图像。但我不能

我的代码是:

<ul class="thumbnails">
          <li class="span4">
            <div class="thumbnail">
              <video data-src="holder.js/300x200" src="http://www.youtube.com/watch?v=jOaOjN-rsIM">
              <div class="caption">
                <h3>Thumbnail label</h3>
                <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                <hr>
                <p><a href="#" class="btn btn-primary">Action</a> <a href="#" class="btn">Action</a></p>
              </div>
            </div>
          </li></ul>
4

1 回答 1

4

尝试使用带有 youtube 嵌入代码的 iframe 作为源。我假设您也希望它具有响应性,因此我也添加了带有“flex-video”类的 div。这是一个Bootply 项目的链接,如果你需要,它应该可以帮助你。

HTML:

        <ul class="thumbnails">
          <li class="span4">
            <div class="thumbnail">


                <div class="flex-video widescreen ">
                  <iframe class="" src="//www.youtube.com/embed/8wqtwkmsBvc" frameborder="0"></iframe>
                </div>   


              <div class="caption">
                <h3>Thumbnail label</h3>
                <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                <p><a href="#" class="btn btn-primary">Action</a> <a href="#" class="btn">Action</a></p>
              </div>
            </div>
          </li>

        </ul>

CSS(用于响应式视频):

         .flex-video {
          position: relative;
          padding-top: 25px;
          padding-bottom: 67.5%;
          height: 0;
          margin-bottom: 16px;
          overflow: hidden;
           }

          .flex-video.widescreen { padding-bottom: 57.25%; }
          .flex-video.vimeo { padding-top: 0; }

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

 @media only screen and (max-device-width: 800px),  
 only screen and (device-width:1024px) and (device-height: 600px), only screen 

 and (width: 1280px) and (orientation: landscape), only screen 

 and (device-width: 800px), only screen and (max-width: 767px) {

 .flex-video { padding-top: 0; }
   }
于 2014-02-21T20:46:51.367 回答