Giter Site home page Giter Site logo

chaseric / covervid Goto Github PK

View Code? Open in Web Editor NEW
1.1K 29.0 187.0 120.47 MB

Make your HTML5 video behave like a background cover image with this lightweight Javascript plugin / jQuery extension

License: MIT License

JavaScript 39.84% CSS 24.97% HTML 35.19%
javascript jquery video

covervid's Introduction

CoverVid

⚠️ This project is no longer maintained now that their is widespread support for the object-fit and object-position CSS properties in modern browsers ⚠️

At the core of CoverVid, is the idea of this little CSS snippet being possible...

.selector {
    background-video: url('../foo/bar.mp4 || ../foo/bar.webm');
    background-size: cover;
    background-position: center center;
}

Why is it special?

CoverVid is very lightweight, with only 800 bytes of Javascripts. It is usable in native Javascript and jQuery. Its' logic is parent based, meaning the parent element can be any size (Not necessarily just a full-screen background).

How do I use it?

  1. First pull the project down from GitHub, or install with bower running bower install covervid and link covervid.min.js into your site. Make sure it is loaded after jQuery if using it.

  2. It is important to note that the video you target will use its' parent element to scale. With that in mind, we will create some simple markup and add some base styling to size the videos' parent/wrapper element.

    <div class="covervid-wrapper">
        <video class="covervid-video" autoplay loop poster="img/video-fallback.png">
            <source src="videos/video.webm" type="video/webm">
            <source src="videos/video.mp4" type="video/mp4">
        </video>
    </div>
    .covervid-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
  3. Now, we would simply call coverVid(Container-Element, Video-Width, Video-Height) on the video element, passing through the native dimensions of the video. If you are using jQuery, we would call $('.covervid-video').coverVid(1920, 1080);.

covervid's People

Contributors

jonathanwolfe avatar chaseric avatar jorinvo avatar tombyrer avatar jheftmann avatar milesmatthias avatar

Stargazers

Max avatar  avatar Cosmo Mathieu avatar  avatar Roman avatar  avatar Weilin Jin avatar  avatar curiousbutton avatar  avatar Indrit avatar Lumex avatar Cat  avatar Logan King (DarkComet) avatar LGD.HuaFEEng avatar Anton Ingerman avatar fxioi avatar Pankaj Kumar avatar Abu Salam Parvez Alam avatar  avatar  avatar Kristjan Koppel avatar Damien Johnson avatar  avatar Dicky Chan avatar Statanis 123 avatar Dominik Kucharski avatar Frank Diao avatar Tadashi Shigeoka avatar Aurélie avatar  avatar Yubo avatar Armon Roberts avatar  avatar Naqi avatar  avatar Ken.Wong avatar Scott Walter avatar Zacharie Kenneth Happel avatar  Damon Đ Phạm avatar  avatar Jose Rios avatar Sebastian Richter avatar  avatar Luhengqi avatar 林锋 avatar Jérôme Coppée avatar Giulia Nicole Pernice avatar  avatar Shauny avatar Roberto Capannelli avatar Abdul Rehman avatar hooke avatar  avatar Bill Ho avatar Manuel Abarca avatar Hasitha Sandaruwan avatar Erikson avatar Toru KOKUBUN avatar  avatar Mahdi Alavi avatar  avatar  avatar Taylor Wiley avatar Jonas avatar Kento avatar Ian avatar kingalysterian avatar Greg Mathews avatar Erol Bakir avatar Sky Yip avatar Yassin avatar Tal Haberer avatar MOИK avatar Ciro Peralta avatar Maya Fiuza avatar Roman Markelov avatar Patrick Villanueva avatar  avatar Ross Barnes avatar  avatar Dinesh Kesarwani avatar Philipp avatar Silas Ribas Martins avatar Max Eise avatar kerwin avatar  avatar Paulo Sá avatar Blago Eres avatar Madalin Tache avatar Emanuel Schmitt avatar daniel sieradski avatar Łukasz Głuszek avatar Simon Phumin Schweikert avatar wolkai avatar  avatar Vanderson Arruda avatar ShuaiHua Du avatar Julian Laval avatar Tom Nick avatar

Watchers

 avatar André Philip avatar Zachery Rodgers avatar Jessie Matanky avatar  avatar  avatar A. Yusuf Besim avatar  avatar Nico Redick avatar Michael Anthony avatar  avatar Gerardo avatar Nicolas Amendola avatar Tuna Aras avatar Vlad Dubov avatar Anh Ta avatar aaron.dev avatar  avatar  avatar Lim Jenq Ning avatar  avatar Syed Peer avatar  avatar  avatar  avatar  avatar  avatar Albert avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.