D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
emilbayes
Full window
Github gist
Make one element cover another proportionately
<!doctype html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="main.css"> </head> <body> <div class="container"> <img src="https://phaseoneimageprofessor.files.wordpress.com/2013/07/iqpw29_main_image_.jpg" alt=""> </div> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script src="coverElement.js"></script> <script> $(window).load(function() { $container = $('.container'); //$('html'); //Use html to fit in viewport $img = $container.find('img'); $img.coverElement({ container: $container //Can be element, jQuery object or selector }); }); </script> </body> </html>
https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js