In this post we learn how to create a full screen video background using HTML and CSS. The video background is always 100 percent height and width of the browser. We then overlay some text on top of our video background, and place some content below our full scree video background which is viewable when the page is scrolled.
Step 1: Setup the HTML
The HTML is very simply. We create a container div which will hold our video, overlays, and image. The full screen video background will be displayed on desktop and the image will replace the video when viewing the site on a mobile device.
<div class="background-video-container"> <video class="background-video-element" autoplay muted loop > <source src="assets/background_video.mp4" /> </video> <img class="background-video-image" src="assets/background_video_image.png" /> <div class="background-video-overlay"></div> <div class="background-video-text-overlay"> Easy, Code Is </div> </div> <div class="content"> CONTENT BELOW THE FULL SCREEN VIDEO BACKGROUND! </div>
Step 2: Style it up with CSS!
Now that we have our HTML setup, all that is left to do is apply some styles to the classes we created for each of our HTML elements.
.background-video-container class
This is our container class around everything. It holds our video, video overlays, and image for mobile. Position absolute with top, left, right, bottom, of zero, will keep it in our browsers view. The overflow hidden will remove and scroll bars caused by the contents inside of the div. The media query makes sure that on mobile the position changes to relative. This allows the image to adjust to 100% width of the mobile device and allows the content under the image on mobile to always be right under the image.
.background-video-container { position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; z-index: -100; } @media screen and ( max-width: 800px ) { /* mobile */ .background-video-container { position: relative; } }
.background-video-element class
This is the actual video element. The video will always take up the entire view port, 100 percent width and height. When the browser gets resized, the video will be centered in the browsers view port because we have the transforms set to -50%. After defining the class, we need to also add the class to both the desktop and mobile media queries. On desktop we want to display the video, and on mobile we want to hide the video.
.background-video-element { position: absolute; top: 50%; left: 50%; min-width: 100%; min-height: 100%; width: auto; height: auto; z-index: -100; -ms-transform: translateX( -50% ) translateY( -50% ); -moz-transform: translateX( -50% ) translateY( -50% ); -webkit-transform: translateX( -50% ) translateY( -50% ); transform: translateX( -50% ) translateY( -50% ); } @media screen and ( min-width: 800px ) { /* desktop */ .background-video-element { display: block; } } @media screen and ( max-width: 800px ) { /* mobile */ .background-video-element { display: none; } }
.background-video-image class
This is the class for our image. On desktop we want to hide the image, and on mobile we want to display the image. So, we add our class to both the desktop and mobile media queries.
@media screen and ( min-width: 800px ) { /* desktop */ .background-video-image { display: none; } } @media screen and ( max-width: 800px ) { /* mobile */ .background-video-image { display: block; width: 100%; } }
.background-video-overlay class
This class is our dark overlay. We give it a little opacity so we can see through the black background to the video playing. This allows the text we place on top of the video to be more readable and it looks much cleaner. We only display this on desktop because our image is already dark enough that any text overlay we place on the image for mobile will look good.
@media screen and ( min-width: 800px ) { /* desktop */ .background-video-overlay { height: 100%; width: 100%; position: absolute; background: rgba( 1, 1, 1, 0.8 ); } } @media screen and ( max-width: 800px ) { /* mobile */ .background-video-overlay { display: none; } }
.background-video-text-overlay class
This is the text we are placing on top of our video on desktop and image on mobile. We setup the defaults for this div so that the text is always in the center of the browser with translate, top, left set to 50% along with text align of center. Color of the text is set to white, #FFF, and font is nice and big at 90px. Only thing we are changing for mobile view is the font size, we are bring that down to 30px for mobile devices.
.background-video-text-overlay { position: absolute; top: 50%; left: 50%; transform: translate( -50%, -50% ); color: #fff; font-size: 90px; text-align: center; } @media screen and ( max-width: 800px ) { /* mobile */ .background-video-text-overlay { font-size: 30px; } }
.content class
The content class is everything under the full screen video background. We define the class first and give it some margin and make sure the text is centered. The key style here is the styles in the desktop media query. Since our video is always 100 percent of the height of our browser window, we need to give our content a margin top of 100 percent of the browser window. In the media query, the “margin: 100vh 0 0 0;” sets the margin top to 100 percent of the browsers view port height (100vh). Now our content div always starts right below the height of the browser because it has a margin top of 100 percent of the browsers view port height.
.content-inner { text-align: center; margin-top: 20px; margin-bottom: 40px; display: inline-block; } @media screen and ( min-width: 800px ) { /* desktop */ .content { margin: 100vh 0 0 0; width: 100%; } }
That is how we create a full screen video background using HTML and CSS. Well, that is going to do it for this post, leave a comment, let me know what you want to learn and see implemented next.
Links
The full code example can be found in the GitHub link above along with a live demo! The video tutorial for this can also be found in the YouTube link above. That is going to do it for this post! Leave any comments/questions/concerns below and thanks for stopping by the blog!
Seedkeeper – Seedphrases and passwords manager https://satochip.io/product/seedkeeper/
What’s up tto eery one, thhe contnts pressent att this wesite are really remarkable for people
experience, well, keep uup the nice work fellows.
Having rerad this I believed it wass very informative.
I appreciate yoou takong the time aand effort tto put ths informative article
together. I oonce again finhd mysself spending wayy too much tikme both reading
annd lleaving comments. Butt soo what, itt was still worth it!
Muchos Gracias for your blog. Really Cool.
Aw, this was an incredibly nice post. Taking the time and actual effort to make a good article… but what can I say… I put things off a whole lot and don’t manage to get nearly anything done.
ต้องยอมรับว่าคาสิโนออนไลน์ เป็นช่องทางการเดิมพันที่ทั้งสะดวกและปลอดภัย เว็บการพนันออนไลน์อันดับ 1 ที่ได้รับการยอมรับมากมายจากสาวกพนันออนไลน์ว่าจ่ายจริงจ่ายเต็ม ทำเงินได้จริง ที่สุดของเว็บคาสิโนออนไลน์ต้อง แทงบอลออนไลน์
This piece of writing provides clear idea for the newpeople of blogging, that truly how to do running a blog.
what is cymbalta duloxetine medication cymbalta medication for pain
tractor supply ivermectin pour-on can humans take ivermectin horse paste
Awesome post.Much thanks again. Really Cool.
Very good blog post.Really thank you! Will read on…
This is one awesome article.Really thank you! Will read on…
Im thankful for the article.Thanks Again. Want more.
A big thank you for your post.Really looking forward to read more. Great.
The otrher day, while I wass at work, my sister stole
mmy apple ipad annd tested to seee iff iit ccan survive a forty foot
drop, just so shhe can bee a youtube sensation.
My iPadd is now bdoken and shhe has 83 views.
I know this is completely off topic buut I hadd tto share itt wuth someone!
Great, thanks for sharing this blog article.Much thanks again. Much obliged.
Really enjoyed this article.Thanks Again. Awesome.
I want to to thank you for this fantastic read!! I absolutely loved every bit of it. I’ve got you saved as a favorite to check out new things you postÖ
I am not sure the place you’re getting your information, however good topic. I must spend a while learning much more or understanding more. Thank you for excellent info I was looking for this info for my mission.
Thanks for the auspicious writeup. It actually used to be a amusement account it. Look complex to more delivered agreeable from you! By the way, how can we communicate?
I wanted to thank you for this very good read!!I definitely enjoyed every little bit of it. I have youbook-marked to check out new things you post…
Thanks-a-mundo for the article post.Much thanks again. Much obliged.
Tremendous issues here. I am very satisfied to see your article.Thank you so much and I’m looking ahead to touch you.Will you kindly drop me a e-mail?
I read this post fully about the comparison of hottest and earlier technologies, it’s amazing article.
lasix and kidney stones lasix med can lasix and hctz be taken together
Im grateful for the article. Fantastic.
Seriously all kinds of great tips!community service essay sample how to write an argument essay writing services online
I think this is a real great blog post.Thanks Again. Will read on…
Say, you got a nice article.Really looking forward to read more. Want more.
Cheers! I enjoy this!how to write a bibliography for an essay argumentative essay review writing service
Thanks a lot for the post.Really looking forward to read more. Keep writing.
Hi just wanted tto giv you a brieef heazds
upp and let you know a feww of the iages aren’t loadinng properly.
I’m not sure why but I think itss a linkijng issue. I’ve ttried iit in twwo difderent internet browesers and bkth show
thee sme results.
There is definately a lot to know about this topic.I really like all of the points you have made.
I do not even know how I ended up here, but I thought thispost was good. I do not know who you are but certainly you’re going to a famous blogger if you aren’talready 😉 Cheers!
It iis perfect time to make a few pplans forr the futuree annd it’s tiime tto be happy.
I’ve learn this submit andd if I mmay jyst I wish
to sugges youu somee attention-grabbing isssues oor
advice. Maye you could writye next articles relating too thus
article. I desire to larn more thinhs aplroximately it!
It’s actually a nice and useful piece of information. I’m satisfied that you simply shared this helpful information with us.Please keep us up to date like this. Thank you for sharing.
Thank you for another magnificent article. The place else may just anybody get that kind of information in such an ideal way of writing? I’ve a presentation next week, and I’m at the search for such information.
You made several fine points there. I did a search on the topic and found a good number of people will have the same opinion with your blog.
Wow! This could be one particular of the most helpful blogs We have ever arrive across on this subject. Basically Fantastic. I’m also an expert in this topic therefore I can understand your hard work.
Very informative blog post. Want more.
Very good written story. It will be valuable to everyone who usess it, as well as yours truly :). Keep doing what you are doing – looking forward to more posts.
I am not sure where you are getting your information,but good topic. I needs to spend some time learning much moreor understanding more. Thanks for magnificent info I was lookingfor this info for my mission.
This very blog is no doubt educating as well as diverting. I have found a bunch of handy advices out of it. I ad love to visit it again and again. Thanks a bunch!
I appreciate you sharing this blog article. Awesome.
Heya i’m for the first time here. I came across this boardand I find It truly useful & it helped me out a lot.I hope to give something back and aid others like you helped me.
There is certainly a great deal to find out about this topic. I really like all of the points you’ve made.
Yes! Finally something about 2nd card.Review my blog … Ellie
reputable indian online pharmacy erectile dysfunction pills – save on pharmacylegit mexican pharmacy
I appreciate you sharing this post.Thanks Again. Will read on…
When someone writes an piece of writing he/she keeps the thought of a user in his/her brain that how a user can knowit. Thus that’s why this article is amazing. Thanks!
Ichhyj – canada pharmacy daily tadalafil Uisiqi vfjtot
It’s actually a great and useful piece of information. I am glad that you just shared this useful information with us. Please keep us up to date like this. Thank you for sharing.
great points altogether, you just gained a new reader. What would you suggest in regards to your post that you made a few days ago? Any positive?
whoah this weblog is fantastic i love studying your posts. Stay up the great work! You already know, lots of persons are hunting around for this information, you could help them greatly.
This design is steller! You obviously know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!
magnificent post, very informative. I wonder why the other specialists of this sector don’t notice this. You must continue your writing. I’m sure, you have a great readers’ base already!
What i don’t understood is actually how you are now not actually a lot more well-preferred than you may be now. You’re very intelligent. You understand therefore significantly when it comes to this matter, produced me in my opinion imagine it from so many various angles. Its like women and men don’t seem to be fascinated unless it is one thing to do with Lady gaga! Your personal stuffs excellent. At all times care for it up!
What’s Happening i’m new to this, I stumbled upon this I have discovered It absolutely useful and it has aided me out loads. I am hoping to contribute & assist other users like its aided me. Good job.
Hello colleagues, its wonderful paragraph on the topic oftutoringand entirely explained, keep it up allthe time.
Greetings! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!
It is perfect time to make some plans for the future and it’s time to be happy. I have read this post and if I could I wish to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I desire to read even more things about it!
Hiya, I’m really glad I have found this information. Nowadays bloggers publish only about gossips and net and this is actually irritating. A good site with exciting content, that’s what I need. Thank you for keeping this web-site, I’ll be visiting it. Do you do newsletters? Can’t find it.
I have been absent for a while, but now I remember why I used to love this web site. Thanks , I will try and check back more frequently. How frequently you update your web site?
Hello There. I found your blog the use of msn. This is a very well written article. I will make sure to bookmark it and come back to learn more of your useful information. Thank you for the post. I’ll certainly comeback.
Hello there, just became alert to your blog through Google, and found that it’s really informative. I am going to watch out for brussels. I will appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers!
I do consider all the concepts you have presented for your post. They’re very convincing and will definitely work. Still, the posts are too brief for starters. May just you please prolong them a bit from next time? Thanks for the post.
Enjoyed every bit of your article post.Really thank you! Much obliged.
Thank you ever so for you post.Really thank you! Really Great.
High Exposure To Nicotine Among Adolescents Who Use Juul And Other Vape Pod Systems (‘Pods’)
Muchos Gracias for your article.Thanks Again. Fantastic.
A round of applause for your article post.Really looking forward to read more. Cool.
This is one awesome blog.Really looking forward to read more. Want more.
A big thank you for your blog article.Much thanks again. Really Cool.Loading…
Appreciate you sharing, great blog post.Thanks Again. Really Great.
Awesome blog post.Really thank you! Fantastic.
Thanks a lot for the blog article.Really thank you! Will read on…
provigil for adhd – modafinil moa modafinil reviews
Really informative blog post.Thanks Again. Awesome.
Great, thanks for sharing this blog article. Will read on…
Major thanks for the post.Thanks Again. Keep writing.
Thank you for your article post. Awesome.
I appreciate you sharing this blog post.Really looking forward to read more. Fantastic.
Thanks for the post.Much thanks again.
i need help writing a paper for college writing essays help
Wow, great post.Really thank you! Want more.
It’s an amazing post designed for all the internet people; they will obtain advantagefrom it I am sure.
Say, you got a nice blog post.Thanks Again. Great.
Awesome blog post.Much thanks again. Will read on…
I think this is a real great post.Really thank you! Really Great.
Heya are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you require any html coding knowledge to make your own blog? Any help would be really appreciated!
Thanks a lot for the article.Thanks Again. Much obliged.
Im obliged for the blog.Much thanks again. Much obliged.
Im obliged for the post.Really looking forward to read more. Really Cool.
Thanks a lot for the blog article.Much thanks again.
This article is actually a fastidious one it assists new internet people,who are wishing in favor of blogging.
Wow that was strange. I just wrote an incrediblylpng comment buut after I clicked submit my commentdidn’t appear. Grrrr… well I’m not writinng all thatover again. Anyways, just wanted tto say superb blog!
I have read so many articles or reviews regarding the blogger lovers but this article is truly a good pieceof writing, keep it up.
An intriguing discussion is definitely worth comment. I do think that you ought to publish more about this topic, it may not be a taboo subject but typically people do not discuss these subjects. To the next! All the best!!
Very neat blog article.Much thanks again. Cool.
I uѕed to be aЬle to find good info frοm your content.
ed pills at walgreen – erectile dysfunction pills laws in colorado is microgynon 30 ed a mini pill
Thanks for the blog article.Really looking forward to read more. Keep writing.
modafinil anxiety – provigil schedule modafinil side effects
I really like and appreciate your article.Much thanks again.
I really like reading through an article that can make people think. Also, thank you for permitting me to comment!
azithromycin loperamide – azithromycin walgreens over the counter zithromax tripak
Thanks for finally talking about > Slightly Stoopid,Tribal Seeds, Matisyahu and Hirie at Red Hat Amphitheater in Raleigh,NC: Part 1 – INDRA Magazine
Hi my friend! I wish to say that this post is awesome, great written and include approximately all vital infos. I’d like to look more posts like this .
Thanks a lot for the article post.Much thanks again. Fantastic.
Looking forward to reading more. Great post.Really thank you! Fantastic.
I truly appreciate this post.Much thanks again. Fantastic.
Major thanks for the blog article.Really looking forward to read more. Much obliged.
Muchos Gracias for your blog article.Thanks Again. Great.
Really enjoyed this blog post.Really looking forward to read more. Really Great.
I really enjoy the article post.Really looking forward to read more. Keep writing.
Thanks for sharing, this is a fantastic blog article.Really thank you! Fantastic.
I have been reading out many of your articles and i can state pretty good stuff. I will make sure to bookmark your blog.
Heya are using WordPress for your blog platform?I’m new to the blog world but I’m trying to get started and create my own. Do you need any html coding expertise to make your own blog?Any help would be really appreciated!
Very informative article.Really thank you! Want more.
Enjoyed every bit of your article.Really looking forward to read more. Great.
Say, you got a nice blog article.Really looking forward to read more. Cool.
Awesome article.Really looking forward to read more. Will read on…
Hello my friend! I wish to say that this article is amazing, nice written and come with almost all important infos. I’d like to peer more posts like this.
I really liked your article. Keep writing.
Very informative article post. Will read on
Thanks again for the blog post. Will read on…
What’s Taking place i’m new to this, I stumbled upon this I have discovered It positivelyhelpful and it has aided me out loads. I’m hoping tocontribute & help different users like its aided me.Good job.
side effects of modafinil modalert vs modvigil provigil flmodafinil
Hello there, just became alert to your blog through Google, andfound that it is truly informative. I’m gonna watch out for brussels.I’ll appreciate if you continue this in future. Many people will be benefited from your writing.Cheers!
Hey, thanks for the post.Much thanks again. Really Cool.
https://microsoft-powerpoint-2010.softonic.kr/download
I needed to thank you for this fantastic read!! I absolutely loved every bit of it. I have you book-marked to check out new stuff you post…
Hello there! I simply wish to offer you a huge thumbs up for your great information you have here on this post. I will be returning to your blog for more soon.
Thanks again for the article. Will read on…
A round of applause for your blog post.Much thanks again. Will read on…
Awesome blog. Great.
Enjoyed every bit of your blog post.Really thank you! Fantastic.
Major thanks for the article post.Really looking forward to read more. Want more.
Great post. I was checking continuously this blog and I’m impressed!Extremely useful information specifically the final part 🙂 I care for such info a lot.I used to be looking for this certain info for a very lengthytime. Thanks and good luck.
Simply click the ‘Coupon’ tab to view currently availablecouponsFree Coupons – Get Free Coupon Online – Store ShippingCouponfree coupons
Muchos Gracias for your article post.Thanks Again. Will read on…
Great, thanks for sharing this blog.Really looking forward to read more. Much obliged.
Really enjoyed this article post.Thanks Again. Awesome.
walgreens ivermectin how to use ivermectin for dogs
I am not very superb with English but I get hold this rattling easygoingto read.Here is my blog post :: Hwa
Thanks so much for the blog article. Keep writing.
I am so grateful for your post. Will read on…
I’m curious to find out what blog platform you happen to be utilizing? I’m having some small security issues with my latest blog and I would like to find something more safeguarded. Do you have any recommendations?
There’s definately a lot to find out about this subject. I love all of the points you made.
Appreciate you sharing, great post.Really looking forward to read more. Keep writing.
topic. I needs to spend some time learning much more
ivermectin us – generic stromectol online ivermectin 6 tablet
Really appreciate you sharing this blog article.Really thank you! Want more.
Looking forward to reading more. Great article.Really thank you! Want more.
Incredible! This blog looks exactly like my old one!It’s on a completely different topic but it has pretty much the same layoutand design. Wonderful choice of colors!
Thank you for the auspicious writeup. It in fact was a amusement account it.Look advanced to more added agreeable from you! However, how could wecommunicate?
Heya i am for the primary time here. I came across this board and Ito find It truly useful & it helped me out a lot.I am hoping to give something back and help others such as you aided me.
I am continuously searching online for posts that can benefit me.Thank you!my blog post – clubriders.men
Thanks for helping out, superb info. Job dissatisfaction is the number one factor in whether you survive your first heart attack. by Anthony Robbins.
Thanks for sharing, this is a fantastic article.Thanks Again. Cool.
Say, you got a nice post.Really thank you! Want more.
I loved your blog post.Much thanks again. Really Great.
Thanks a lot for the post.Thanks Again. Fantastic.
Appreciate you sharing, great blog post. Cool.
Thank you for your article.Really looking forward to read more. Will read on…
I loved your blog.Really looking forward to read more. Will read on…