覆盖对象顶部的文本

时间:2014-09-21 04:07:04

标签: html css twitter-bootstrap

我的网站上有一个youtube视频。我想知道是否有任何方法可以在视频的顶部布置文本以给它一个特定的标题。

另外,我会如何做同样的事情,但在视频的左侧?我也在使用bootstrap。

1 个答案:

答案 0 :(得分:1)

您可以使用z-index或按位置来执行此操作。

<div class="container">

<iframe width="560" height="315" src="//www.youtube.com/embed/YXVoqJEwqoQ" frameborder="0" allowfullscreen></iframe>
    <div class="my-text"> This is my text</div>
    </div>

CSS

body {
    background: #efefea
}

.container {
    width: 600px; 
    margin: 0 auto; 
    padding: 10px;
    position: relative; 
}

iframe {
    marign: 0 auto; 
}

.my-text {
    position: absolute;
    color: #fff;
    padding: 10px 0px;
    text-align: center; 
    font-size: 50px; 
    background: rgba(0,0,0, 0.5);
    top: 20px;
    left: 0; 
    right: 0;
}

http://jsfiddle.net/websiddu/dy4exbcp/1/

相关问题