jQuery Plugin To Resize Background Image To Fit Screen

jQuery Plugin To Resize Background Image To Fit Screen
File Size: 400 KB
Views Total: 2838
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Background Fit is a jQuery plugin for responsive design that resizes the background image to fit your screen/container. The plugin will preserve your background image's aspect ratio when resized, without losing any quality.

How to use it:

1. Add the jQuery library and the JQuery background fit plugin to your web page.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="jquery.background-fit.min.js"></script>

2. Set a background image for your container in the CSS.

#bg {
  background: url(background.jpg);
  background-size: 100%;
  background-repeat: no-repeat;
}

3. Call the plugin on the container and you're done.

$(function() {
  $("#bg").bg_fit();
});

This awesome jQuery plugin is developed by thingsym. For more Advanced Usages, please check the demo page or visit the official website.