jquery CSS doesn't work in webkit
- by Mauro74
I'm trying to apply some css to an image tag if the image is portrait, but for some reason .css() doesn't work in webkit. Basically the image tag doesn't get the 'style' property. Here's my code:
$(document).ready(function () {
$('.listing .item .thumb img').each(function () {
var _img = $(this);
var _imgWidth = _img.outerWidth();
var _imgHeight = _img.outerHeight();
if (_imgHeight > _imgWidth) {
_img.css('top', '-40%');
}
});
});
<div class="listing about">
<div class="item">
<a href="#" class="thumb">
<img src="../_uploads/siteassets/images/thumb-carousel-2.jpg" />
<span class="frame"></span>
</a>
<span class="snippet">
<a href="#" class="title">Name Surname</a>
<span class="date">Role in the company</span>
<p class="description">Lorem ipsum dolor sit amet...</p>
</span>
</div>
</div>
I've tried to use .attr() instead of .css() but nothing. It doesn't work!
Any idea why?