OK

CSSJockey websites use cookies to give you a better user experience on our websites. Visit our Privacy and Cookie policy to get more information about cookies, including how you could opt-out.

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, ac...

published: 4 years ago

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.

 
 

pre-built solutions

Speed-up the launch of your web projects with our ready-to-use plugins, themes and widgets!

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis nat...
This WordPress Plugin enables an under-construction page for your WordPress website visitors. Administrators, selected u...