Start typing to search...

Searching for "{{search_term}}"

Search results for "{{search_term}}"

Oops! Nothing found based on your query.

 
{{auth_form.errors}}

No account found with this email address. Fill out this form to create an account.

 

Expand Images to parent DIV with jQuery and CSS

Posted on May 14, 2015 by Mohit Aneja in CSS, jQuery, Tips & Tricks.

Expand Images to parent DIV with jQuery and CSS

Working on a WordPress project where client demands all images within a post should extend and touch window borders, actually full-size images. 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 20px margin.

I got this working with 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.