【问题标题】:I am trying to embed a youtube video in my webpage but it does not show at all我正在尝试在我的网页中嵌入一个 youtube 视频,但它根本没有显示
【发布时间】:2016-01-30 02:03:38
【问题描述】:

我是 HTML 编程新手,所以请多多包涵。为什么嵌入的 you tube 视频不显示?我在这里错过了什么吗?我还包括了 CSS 文件,以备不时之需。

<!DOCTYPE html>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
    <title>Mysteries</title>
    <meta charset="utf-8">
</head>

<html>
<body class="index">

<div id="header_box">
    <h4 class="logo">MYSTERIES<span class="orange2">/</span>PARANORMAL</h4>
    <a  href="index2.html" id="content_link">CONTENT</a>
</div>


<div id="footer">
    <h4>&#60;OKLAH/WEBSOFT&#62; 2015 All Rights Reserved.</h4>
<div>

<iframe width="560" height="315" src="https://www.youtube.com/embed  /Gas8f7dJfWc?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>

</body>
</html>


Here is the CSS Code for the webpage, please keep in mind im new  to all this, so i might have some css errors in there

#header_box {
z-index: 1;
position: fixed;
background-color: rgba(255,255,255,0.25);
border: 1px solid #FFF;
width: 100%;
height: 22px;
left: -2px;
padding: 1em 1.5em;
padding-top: 1em;
padding-right: 1.5em;
padding-bottom: 1em;
padding-left: 1.5em;
top: 0px;

}

.index {
background: #000;
}

.logo {
color: white;
font-family: Verdana;
font-weight: 300px;
float: left;
padding-top: 0px;
margin-top: 0px;
font-size: 16px;


}

}
.orange2 {
color: #FF6600;
}
.orange {
color: #FF6600;
}
.h2 {
color: #FFF;
text-align: center;
padding-top: 10px;
font-family: ISOCT;
letter-spacing: 0.1em;
text-transform: uppercase;
}
img {
float: center;
width: 55px;
height: 50px;
padding-top: 70px;
display: block;
margin: auto;
}

p {
color: #FFF;
text-align: center;
font-family: ISOCT;
font-size: 20px;

}
#paranormal_cont {
color: #FFF;
font-family: Verdana;
float: right;
text-decoration: none;
margin-right: 20px;
}
#paranormal_cont:hover{
border: 1px;
border-style: dotted;
font-weight: bold;
color: #FF6600;
}
#content_link {
color: #FFF;
font-family: Verdana;
float: right;
text-decoration: none;
margin-right: 50px;
}

#content_link:hover {
border: 1px;
border-style: dotted;
font-weight: bold;
color: #FF6600;

}

#footer {

position: fixed;
bottom: 0px;
margin: 0;
padding: 0;
left: 0;
right: 0;
background-color: rgba(255,255,255,0.25);
border: 1px solid #FFF;
width: 100%;
height: 40px;
left: -1px;
}

#footer h4 {
position: relative;
text-align: left;
color: #FFF;
font-family: Verdana;
font-size: 14px;
font-weight: 300px;
margin-left: 10px;
margin-top: 10px;}

【问题讨论】:

    标签: html css video youtube embed


    【解决方案1】:

    问题是您忘记关闭页脚 div。这就是您没有看到 iframe 的原因。

    另外,为了完整起见,“更改链接,使其没有空格”,尽管您已经排除了它是一个问题,因为您说过

    其实原代码没有空格,所以链接就ok了, 还能是什么?

    为了完整起见,这里有完整的工作代码。

    <!DOCTYPE html>
    <html>
    <head>
        <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
        <title>Mysteries</title>
        <meta charset="utf-8">
    </head>
    
    <html>
    <body class="index">
    
    <div id="header_box">
        <h4 class="logo">MYSTERIES<span class="orange2">/</span>PARANORMAL</h4>
        <a  href="index2.html" id="content_link">CONTENT</a>
    </div>
    
    
    <div id="footer">
        <h4>&#60;OKLAH/WEBSOFT&#62; 2015 All Rights Reserved.</h4>
    </div> <!-- You forgot to close this div -->
    
    <iframe width="560" height="315" src="https://www.youtube.com/embed/Gas8f7dJfWc?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
    
    </body>
    </html>
    

    【讨论】:

    • 原来的代码其实是没有空格的,所以链接没问题,还能是什么?
    • 我将使用有效的完整代码更新我的答案。它不适合你,你能打开你的控制台看看有没有错误吗?
    • 好的,我检查了控制台,但它没有显示任何错误
    • 好的,我检查了你的 CSS。例如,将您的页脚高度设置为 400 像素,您将看到视频。所以 iframe 没有任何问题。这是css。
    • 我现在看到了,但是好吧,为什么它会显示在页脚而不是正文上?
    【解决方案2】:

    YouTube 视频的 URL 中有一个空格。删除它。

    改变这个:

    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed /Gas8f7dJfWc?rel=0&amp;amp;showinfo=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

    到这里:

    &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/Gas8f7dJfWc?rel=0&amp;amp;showinfo=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

    更新 你也没有关闭你的页脚。

    我更新了小提琴: JSFiddle

    【讨论】:

    • 原来的代码其实是没有空格的,所以链接没问题,还能是什么?
    • 这是一个jsfiddle,表明它在空间被删除时工作。
    • 也许你有一些影响它的 CSS。如果您认为这可能是一个问题,您可以在您的问题中包含您的 CSS...
    • 我现在包含了 CSS 代码,请再看一遍,谢谢。
    • 你没有关闭你的页脚
      ,没有 CSS 我没有注意到。
    猜你喜欢
    • 2013-01-06
    • 1970-01-01
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 2015-02-04
    • 1970-01-01
    相关资源
    最近更新 更多