jQuery Plugin To Resize Background Image To Fit Screen

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

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="/path/to/cdn/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();
});

Changelog:

2022-02-18

  • v0.0.6

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