将YouTube视频添加到照片库

时间:2018-03-09 20:04:53

标签: html css youtube

我在这里有一个照片库:https://www.metaldepotinc.com/gallery.aspx但是想要一个选项,当有人点击YouTube视频的缩略图时,它会像图片那样展开。这甚至可能吗?这是编码:



   function myFunction(imgs) {
        var expandImg = document.getElementById("expandedImg");
        var imgText = document.getElementById("imgtext");
        expandImg.src = imgs.src;
        imgText.innerHTML = imgs.alt;
        expandImg.parentElement.style.display = "block";
      }

      * {
        box-sizing: border-box;
      }

      body {
        margin: 0;
        font-family: Arial;
      }

      /* The grid: Four equal columns that floats next to each other */
      .column {
        float: left;
        width: 20%;
        padding: 5px;
      }

      /* Style the images inside the grid */
      .column img {
        opacity: 0.8; 
        cursor: pointer; 
      }

      .column img:hover {
        opacity: 1;
      }

      /* Clear floats after the columns */
      .row:after {
        content: "";
        display: table;
        clear: both;
      }

      /* The expanding image container */
      .container {
        position: relative;
        display: none;
      }

      /* Expanding image text */
      #imgtext {
        position: absolute;
        bottom: 15px;
        left: 15px;
        color: white;
        font-size: 20px;
      }

      /* Closable button inside the expanded image */
      .closebtn {
        position: absolute;
        top: 10px;
        right: 15px;
        color: white;
        font-size: 35px;
        cursor: pointer;
      }

<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <div style="text-align:center">
      <h2>Updike Barndominium</h2>
      <p>Click on the images below to enlarge:</p>
    </div>
    <!-- The 5 columns -->
    <div class="row">
      <div class="column">
        <img src="Updike1.jpg" alt="Updike Barndominium" style="width:100%" onclick="myFunction(this);">
      </div>
      <div class="column">
        <img src="Updike2.jpg" alt="Updike Barndominium" style="width:100%" onclick="myFunction(this);">
      </div>
      <div class="column">
        <img src="Updike3.jpg" alt="Updike Barndominium" style="width:100%" onclick="myFunction(this);">
      </div>
      <div class="column">
        <img src="Updike4.jpg" alt="Updike Barndominium" style="width:100%" onclick="myFunction(this);">
      </div>
      <div class="column">
        <img src="https://www.youtube.com/watch?v=4g3FfxkYvGQ" alt="" style="width:100%" onclick="myFunction(this);">
      </div>
    </div>

    <div class="container">
      <span onclick="this.parentElement.style.display='none'" class="closebtn">&times;</span>
      <img id="expandedImg" style="width:100%">
      <div id="imgtext"></div>
    </div>

  </body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案