2015-07-12 149 views
8

我在另一个div里面有两个div(#video-wrapper)。把div放在另一个div上面

HTML:

<div class="row"> 
    <div class="video-wrapper col-lg-2"> 
     <div class="video-thumbnail"> 
      <img src="img/img.jpg"> 
      <span class="glyphicon glyphicon-play video-play"></span> 
      <span class="glyphicon glyphicon-info-sign video-info"></span> 
     </div> 
     <div class="video-description"> 
      <p class="title">See and Sea...</p> 
      <div class="video-upload-info"> 
       <p class="by">Franschisil</p> 
       <p class="pubdate">4 days ago</p> 
      </div> 
     </div> 
    </div> 
</div> 

CSS:

.video-wrapper { 
} 

.video-thumbnail { 
    position: relative; 
    height: 110px; 
    box-shadow: 0px 0px 10px 0px; 
} 

.video-description { 
    height: 100px; 
    background-color: white; 
    padding: 5px; 
    word-wrap: break-word; 
    opacity: 0.9; 
} 

现在看起来是这样的:

enter image description here

我想实现的是隐藏#video-description,并diplay它在#video-thumbnail以上时为点击了。我如何实现这一目标?您的帮助和指导将非常感谢。谢谢。

更新

这是我希望它看起来像之前我点击了信息:

enter image description here

而当其点击是这样的:

enter image description here

**更新** 当应用position:absolute.video-description宽度尺寸缩小,如果有较少的字母:

enter image description here

+0

显示的信息,您可以使用jQuery实现这一目标,并显示上面的小图的信息,您可以用位置实现这一目标:在你的CSS绝对 – Shehary

+0

请出示你已经尝试 – charlietfl

+0

@charlietfl我曾尝试使用overflow:hidded – Kakar

回答

1

您需要在CSS是这样的:

.video-wrapper{ 
    position: relative; 
    box-shadow: 0px 0px 10px 0px; 
    overflow: hidden; 
} 

.video-description { 
    position: absolute; 
    display: none; 
    top: 0; 
    left: 0; 
    width: 100%; 
} 

.video-info{ 
    position: relative; 
    z-index: 1; 
} 

的jQuery:

$('.video-info').click(function(){ 
    $('.video-description').fadeToggle(); 
}); 

DEMO

+0

我尝试过使用'position:absolute',但是'.video-description'的宽度会缩小,如果有更少的单词。我已经更新了图像。 – Kakar

+0

因为我设置了'width:100%;'也是。 – lmgonzalves

+0

如果将宽度设置为100%,则宽度超过父div。 – Kakar

0

可以使用jQuery来实现这个

试试下面的代码:

jQuery(".video-description").on('click',function(){ 
    jQuery(".video-description").insertBefore(jQuery(".video-thumbnail")); 

}); 

希望它可以帮助...!

2

你可以通过一些简单的jQuery来实现这一点。

我创建了两个例子给你:

enter image description here

DEMO 1

enter image description here

DEMO 2

当我用下面的jQuery:

// DEMO 1 
$(document).ready(function() { 
    $('.info').click(function() { 
     $('.video-description').slideToggle();   
    }); 
}); 

// DEMO 2 
$(document).ready(function() { 
    var clicked = false; 
    $('.info').click(function() { 
     $('.overlay').slideToggle(); 
     if (!clicked) { 
      $('.info').animate({top: "115px"}, 500); 
      clicked = true; 
     } else { 
      $('.info').animate({top: "0px"}, 500); 
      clicked = false; 
     } 
    }); 
}); 

在这两个演示中,您将找到所有必需的HTML,CSS和jQuery。如果仔细研究代码,您应该可以自己复制效果。不要忘了include jQuery in your document.

+0

它真的很有趣。但我正在使用引导程序来使用它的“col”类来获得响应式页面。 – Kakar

+1

也许这不是你正在寻找的东西,但我喜欢这个答案显示的方式。 –

+0

@Kakar如果你做了一些小的调整,这段代码也应该用引导程序。 –