All Projects → overtrue → relocator.js

overtrue / relocator.js

Licence: MIT License
relocate images to fit image box

Programming Languages

javascript
184084 projects - #8 most used programming language

relocator.js

relocate images to fit image box.

relocator

Usage

html:

...
<div class="container">
    <div class="box">
        <img src="images/height-image.jpg" alt="">
    </div>
    <div class="box">
        <img src="images/width-image.jpg" alt="">
    </div>
</div>
...
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/relocator.min.js"></script>

relocate all images

<script>
    jQuery(document).ready(function($){
        $('.box img').relocate();
    });
</script>

custom

$(imageSelector).relocate($imageBoxSelector);
  • imageBoxSelector Specify picture reference container, default picture parent reference.

example:

<div class="box">
    <div class="img-wrapper">
        <a href=""><img src="" alt=""></a>
    </div>
    <p>The image title</p>
</div>
...
<script>
    jQuery(document).ready(function($){
        $('.box img').relocate('.img-wrapper');  // Actually:$(img).closet(''.img-wrapper'')
    });
</script>

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].