Reframe.js is a javascript plugin that makes elements scale at a fixed ratio
Install via NPM or Bower
npm i reframe.js --save-dev
or
bower i reframe.js --save-dev
- Add
dist/reframe.js
. - Add reframe
css/scss
to yourcss
. reframe
the element you'd like to re-frame.
reframe('iframe'); // Wrap all iFrames in the page
reframe(document.getElementById('my-frame')); // Pass a DOM element
reframe(document.querySelectorAll('.my-targets')) // Pass a live node list
Elements that have been wrapped with reframe will not be wrapped twice.
Reframe.js removes a specified element's height & width attributes
& then wraps that element in div
that is an intrinsic ratio of the original element. This plugin is great for embedded content like iframes
or videos
.
Reframe.js is inspired by FitVids & does what FitVids does but without the need for jQuery
. This makes the plugin highly valuable when including it in a module that has to be very small & with minimal dependencies. Here's a basic codepen example.
This plugin is small - ~1.3kb
unminified & is meant to do 1 thing - wrap elements that aren't responsive & make them responsive. 💪
If you'd like to not use the classname 'js-reframe', just use your own.
reframe('iframe', 'my-classname');
You can use Reframe.js with jQuery as well.
$('iframe').reframe();
// While using a custom class name
$('iframe').reframe('my-classname');