HTML
6
Вклад в тег
#logo {
position: absolute;
width: 40px;
height: 40px;
left: 0;
top: 0;
padding: 4px;
}
var margin = 15; // 15px отступ для наглядности
$('.container').on('resize scroll', function() {
var $container = $(this);
var container_height = $container.outerHeight();
$('.block').each(function(i, block) {
var $block = $(block);
var top = $block.offset().top - $container.offset().top;
var bottom = top + $block.outerHeight();
var is_visible = (bottom > (0 + margin) && top < (container_height - margin));
$block[is_visible ? 'addClass' : 'removeClass']('block-visible');
});
}).trigger('scroll');
.block-visible { background-color: red; }
<meta name="format-detection" content="telephone=no">
<meta http-equiv="x-rim-auto-match" content="none">