Reputation: 5891
I'm trying to make my child div info
fill the parent div video-featured
width, but also I need the child div to be absolute so it can overlap the parent div.
I have manage to accomplish this by using fixed width in child div however I don't want to use fixed width..is there any way to accomplish what I want?
<div class="video-featured col-md-4">
<div class="video">
<video name="media">
<source src="https://fat.gfycat.com/QuerulousGrayGardensnake.webm" type="video/webm" />
</video>
</div>
<div class="info">
<h3 class="title">
<a title="some random title">
Some random text
</a>
</h3>
</div>
</div>
Check on fiddle https://jsfiddle.net/3w73t9yn/ and the followng images illustrates the problem.
Upvotes: 0
Views: 3290
Reputation: 19111
box-sizing: border-box;
. This is so that we can do things like, "make this element 100% wide but also apply padding".video
lets the 100% value fill the entire container. .info
a child of .video
..video
, so that the new .info
child has a proper context for absolute positioning.* {
box-sizing: border-box;
}
.video-featured
{
outline: 0;
position: relative;
}
video
{
width: 100%;
}
.video {
position: relative;
}
.info
{
position: absolute;
bottom: 0px;
left: 0;
height: 60px;
padding-left: 15px;
padding-right: 15px;
width: 100%;
opacity: 0.6;
background-color: #484848;
}
<div class="video-featured col-md-4">
<div class="video">
<video name="media">
<source src="https://fat.gfycat.com/QuerulousGrayGardensnake.webm" type="video/webm" />
</video>
<div class="info">
<h3 class="title">
<a title="some random title">
Some random text
</a>
</h3>
</div>
</div>
</div>
Upvotes: 2