I'm currently working on website for a video producer. He would like to have his demo reel running in the background when you go to his webpage. I'm trying to create a few div elements that will that will be over the video. They will actually right at the top of the webpage, acting sort of like a navbar, but not really.
Here is the code I'm working with. Of course, you won't be able to see the content when it is run, but maybe I have a mistake some where.
.background-wrap {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
top: 0;
left: 0;
background: #353030;
}
#video-background {
position: relative;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: 500;
height: 500;
z-index: 100;
}
#header-container {
position: relative;
display: inline;
z-index: 200;
}
.header-item {
color: white;
letter-spacing: 3px;
text-align: center;
position: absolute;
<div class="background-wrap">
<video width="1700" height="956" autoplay muted loop id="video-background">
<source src="img/reel.mp4" type="video/mp4">
<source src="img/reel.webm" type="video/webm">
<source src="img/reel.ogv" type="video/ogg">
Sorry, your browser doesn't support HTML5 video.
</video>
<div class="row" id="header-container">
<div class="col-md-4">
<div class="header-item">
<h1 id="title">Josh Kelley</h1>
</div>
</div>
<div class="col-md-4">
<div class="header-item">
<h3 id="subtitle" href="https://vimeo.com/204080098" target="_blank">Video Production & Photography</h3>
</div>
</div>
<div class="col-md-4">
<div class="header-item">
<a id="subtitlebutton1" href="#about" class="btn btn-dark btn-lg">About Me</a>
</div>
</div>
</div>
</div>
My biggest problem is when I change my .header-item to position:absolute.
When I inspect the element with developer tools the content is smashed below the video above. You can even see the About Me button is halfway showing.
Here is what it looks like when #header-container changed to position:relative and delete the position css property off .header-item.
I've marked in RED where I want the elements to go. Any help would be amazing.
Sorry I haven't enough time to provide you with complete solution, but:
.background-wrap {
position: relative;
width: 100%;
height: 100%; /*this has effect of 0px in your case*/
overflow: hidden; /*this hides everything that doesn't fit to the container size*/
top: 0;
left: 0;
background: #353030;
}
Here you specified height: 100% but 100% of what? Its a top level element and you set it's child's position to absolute. So the computed height is 0. It would be ok in other cases, but you've set the overflow to hidden...
As I understand, this is why you see nothing when you set the position to absolute.
You should fix all of your sizes keeping in mind that they don't grow to their children's sizes if those children are absolute positioned. After that check your bootstrap's default configurations (is it static by default, is it inline or block and so on).
Related
I'm trying to place a small video behind a banner-like div element. After some time researching I managed to at least show the contents of the div, but the video is nowhere to be seen. If I place them separately both show up, but if I try to stack them on top of each other it disappears.
HTML:
<div id="castle-siege">
<div id="cs-video">
<video id="videocs" width="100%" height="auto" autoplay="autoplay" loop="loop" preload="auto">
<source src=/assets/img/cs.mp4" type="video/mp4">
</video>
</div>
<div id="cs-table">
//content
</div>
</div>
CSS:
#castle-siege {
width: 1000px;
height: 150px;
text-align: center;
position: relative;
overflow: hidden;
}
#cs-video {
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 5;
}
#cs-table {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
z-index: 10;
}
I think in this instance, that you need to set position attribute as well as z index in order to display the video properly. Also ensure your video is present and correct at the set url of course! Set the position of the video to absolute and set the table relative to it, either with a higher or lower z-index, as necessary (higher if you want it to be seen on top of the video)
For purposes of demo, I set the width to 80%, it's prob better to use percentages/ an adjustable unit, rather than setting the width in px.
Hope this helps
#castle-siege {
width: 80%;
height: 150px;
text-align: center;
position: relative;
overflow: hidden;
}
#cs-video {
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
z-index:0;
}
#cs-table {
width: 100%;
height: 100%;
margin-top: 30px;
margin-left: 50px;
color:red;
text-align:left;
position: relative;
z-index:1;
}
<div id="castle-siege">
<div id="cs-video">
<video id="videocs" width="100%" height="auto" autoplay="autoplay" loop="loop" preload="auto">
<source src="http://mirrors.standaloneinstaller.com/video-sample/jellyfish-25-mbps-hd-hevc.mp4">
</video>
</div>
<div id="cs-table">
Hi there, how's it going? There's supposed to be a table here.
</div>
</div>
How can we keep contained bucket-list.mp4 in video-jumbotron. The video is full-width, but depending on the screen size, the video's height runs off the bottom of the page instead of being cut off and contained in <div class="video-jumbotron">, which is the goal of this question.
view
<div class="video-jumbotron">
<video id="bg-video" autoplay="true" loop='true'>
<source src="/assets/bucket-list.mp4" type="video/mp4" />
</video>
<%= image_tag 'goal-setting-bucket-list-website.png' %>
CHALLENGE WHAT YOU DO
TO CREATE THE LIFE YOU WANT
</div>
# Bottom of video appears underneath this <div>
<div style="background-color: white;">
Testing
</div>
css
.video-jumbotron {
padding-top: 25px;
padding-bottom: 40px;
margin-bottom: 20px;
}
#bg-video {
top: 0px;
left: 0px;
right: 0px;
position: fixed;
z-index: -1;
width: 100%;
}
If the #bg-video (video block) is fixed it will have no relation to your parent div .video-jumbotron and it will be relative (fixed) to the body.
We want to relate the video tag -> #bg-video to it's parent -> .video-jumbotron, so we can contain it.
Add these styles in addition to yours (change #bg-video position from fixed to absolute):
.video-jumbotron {
position: relative;
overflow: hidden;
}
#bg-video {
position: absolute;
}
Now the parent div .video-jumbotron has control and can teach the child what not to do :)
I'm using an <embed> element so I can render a PDF inline. It works well in all browsers, but I can't figure out how to have the <embed> take up the entire, available height in my Bootstrap column. Here is a Plunker. You'll need to widen the preview pane to see the columns next to each other.
This is my markup:
<div class="container">
<div class="row">
<div class="col-sm-7">
<div id="pdf-container">
<div id="pdf">
<embed width="100%" type="application/pdf" src="http://pdf.pdf">
</div>
</div>
</div>
<div class="col-sm-5">
Other stuff here
</div>
</div>
</div>
And here is the CSS that isn't completely working:
#pdf-container {
bottom: 20px;
left: 20px;
position: absolute;
right: 20px;
top: 0;
}
#pdf-container #pdf {
height: 100%;
width: 100%;
}
What I'm challenged with is that it seems like you need to set the height directly on the '` element so they even render. Setting the width on them to 100% is effective, but I can't get the height to take up 100% of the available height.
UPDATE: There appear to be a series of Bootstrap classes (.embed-responsive) that may be aimed at handling this, but when I apply it, my <embed> doesn't appear at all. Here is a Plunker for that.
I put mine in responsive iframes. Change the padding-bottom and padding-top: 30px; to suit your needs
/* Flexible iFrame */
.Flexible-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.Flexible-container iframe,
.Flexible-container object,
.Flexible-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<!-- Responsive iFrame -->
<div class="flexible-container">
<object width="100%" data="https://modelica.org/events/modelica2012/authors-guide/example-abstract.pdf?scrollbar=0&toolbar=0&navpanes=0" type="application/pdf">
<embed width="100%" type="application/pdf" src="https://modelica.org/events/modelica2012/authors-guide/example-abstract.pdf?scrollbar=0&toolbar=0&navpanes=0">
</object>
</div>
</div>
I have two divs: #lookbookHeader and #introContent. #lookbookHeader has a video in it with position: fixed, height: 100% and height: auto, which I followed from this tutorial. I would like #introContent to be below #lookbookHeader, regardless of the height, as you see on this page. I am trying to create a page where the video is full viewport when the page loads, and you can scroll down to see additional content below.
I have tried every combination of positioning, floating and display on these two elements to try to get this to work and I just can't get it! Currently #lookbookHeader has no styles because it doesn't seem to matter what I apply to it, as the video styles override it when I apply position fixed. If I don't have fixed on the video, then it doesn't scale or size correctly with width/height. What am I missing?
I know I can use jQuery or JavaScript to get the height of #lookbookHeader when the page loads but wondering if there is a way to do this with CSS only. You can see the page here.
I have checked other posts on SO, such as this one, but all seem to reference a fixed element with a set height which is not the case here.
HTML
<div id="lookbookHeader">
<video autoplay poster="http://lcoawebservices.com/assets/lp_stainless_SliderStop_5.jpg" id="bgvid">
<source src="http://lcoawebservices.com/assets/lp_stainless_Transition_5.webm" type="video/webm">
<source src="http://lcoawebservices.com/assets/lp_stainless_Transition_5.mp4" type="video/mp4">
</video>
<div id="headerContentContainer">
<h1>Lookbook: Spring 2015</h1>
<div class="initial-arrow-small"></div>
</div>
</div>
</div>
<div id="introContent">
<h2>Bienvenue</h2>
<p>Lorem ipsum dolor sit amet</p>
<div class="block red">one</div>
<div class="block blue">two</div>
<div class="block yellow">three</div>
<div class="block green">four</div>
</div>
CSS
#introContent {
max-width: 100%;
height: auto;
background-color: #fff;
}
#lookbookHeader video#bgvid {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
background: url(http://lcoawebservices.com/assets/lp_stainless_SliderStop_5.jpg) no-repeat;
background-size: cover;
display: block;
}
Add a top margin to accomplish this. First you need to include html on the body styles:
html,body { //add html
width: 100%;
height: 100%;
font-family: Helvetica, Arial, sans-serif;
font-size: 11px;
margin: 0;
padding: 0;
}
Then add height:100% to .container (for it's children). Then you can set the height and margin on .introContent. Also you have floated elements inside .introContent that you're not clearing. You can correct that by adding overflow: hidden:
#introContent {
min-height: 100%; //add min-height
max-width: 100%;
height: auto;
background-color: red; //changed so you can see the container better
overflow: hidden; //add to clear floats
margin: 50% 0 0; //add margin from top
}
FIDDLE
UPDATE
I have a better solution. Sometimes you just overthink things. Just simply add a blank div above the content like so:
<div class="spacer"></div>
<div id="introContent">
....
and set it to:
.spacer{
height: 100%;
width: 100%;
}
That will take up the height of the screen and bump your content down below
BETTER FIDDLE
I am tying to have a video tag to fill 100% of a div:
a) it doesn't need to keep the ratios(otherwise we need to use the overflow:none);
b) fill a div, not the whole background;
c) it would be a plus to be responsible. Now it is as long as you re-size window diagonally. Keeping height and re-sizing horizontally cuts the video.
I have tried dozens if not hundreds of alternative, and all of them keep the initial video ratio.
it works in the fidlle .... maybe because the screen is small, maybe because fiddle is a better browser...
<body>
<div class="wrapper">
<div class="header">
.....
</div>
<div class="out-video">
<video autoplay loop poster="mel.jpg" id="bgvid" width="100%" height="100%">
<source src="http://www.mysite.braaasil.com/video/mel.webm" type="video/webm">
<source src="http://www.mysite.braaasil.com/video/mel.mp4" type="video/mp4">
</video>
</div>
</div>
The site is here but as I try the solutions, it will change... There is a right and left sidebar empty. I would like the video to fill the whole width. When it covers the div, the height change and the video does not show in full. I would like something like the background-size 100% 100% that stretches the images to the end of the div, but it does not work for video.
Thank you for any suggestion in advance.
PS. It seems that android family does not play the video!
l
Use object-fit css property, though there is no support for IE, but it's still quite reasonable to be used for <video>, <img> tags.
Check CanIUse for Browser Support, and CSS-Tricks for usage.
Example:
/** If parent has some defined width/height */
.video-element {
width: 100%;
height: 100%;
object-fit: cover;
}
You can use a solution like this one. Ratio dont change, but you may lose the right part of the video.
video#bgvid {
position: absolute;
z-index: 0;
background: url(mel.jpg) no-repeat;
background-size: 100% 100%;
top: 0px;
left: 0px; /* fixed to left. Replace it by right if you want.*/
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
}
The video will be fix to top left corner. If you want to improve it, I think you will need some JavaScript.
Edit :
Just a find a solution with JQuery who can fit your need : simulate background-size:cover on <video> or <img>
Demo
Simple CSS inheit
video {
width: inherit;
height: inherit;
}
div {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: black;
}
Try this
HTML:
<div id="MainBanner">
<video autoplay muted loop>
<source src="something-nice.mp4" type="video/mp4">
</video>
<div class="content">
<h1>Heading</h1>
<p>Some Content</p>
</div>
</div>
Less:
#MainBanner {
position: relative;
height: 100vh;
overflow: hidden;
video {
background: url(cover.jpg) no-repeat;
top: 0px;
left: 0px;
min-width: 100%;
min-height: 100%;
}
.content {
position: absolute;
padding: 20px;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
color: #f1f1f1;
width: 100%;
}
}