Expand Images to parent DIV with jQuery and CSS

Easy Element Toggles with Data Attributes and jQuery.

Working on a WordPress project where the client demands all images within a post should extend and touch window borders, actually full-size images. Applying DIV with jQuery and CSS works. The wrapper has a margin of 20px on both sides and it is not possible to remove the margin otherwise, all other elements will require a 20px margin.

I got this working with the following JS code:

$('.content img').each(function() {
    $(this).css({
        'position': 'relative',
        'min-width': $(window).width(),
        'margin-left': '-20px',
    });
});

In case you have better code for this and in CSS, please share.

DIV with jQuery and CSS
Contact Us

Our Services

Leave a Reply

Your email address will not be published. Required fields are marked *

 
Enquiry Now
iogoos-logo

Our consultants will respond back within 8 business hours or less.

X