body {
font-size: 14px;
padding: 15px 20px;
}
#console {
position: fixed;
top: 0;
left: 50%;
width: 300px;
margin-left: -150px;
text-align: center;
background: #666;
padding: 10px;
opacity: 0.5;
color: #fff;
}
.block {
margin-bottom: 15px;
background-image: linear-gradient(135deg, #ececec, #bfbbbb);
padding: 100px 0;
font-size: 44px;
color: #555;
text-align: center;
display: block;
}
.tsr_test {
display: block;
height: 280px;
width: 100%;
margin: 10px;
background-color: #fff;
overflow: hidden;
border-radius: 3px;
}
.tsr_test .image {
width: 100%;
height: 180px;
overflow: hidden;
}
.tsr_test img {
width: 100%;
height: 100%;
}
.tsr_test .title {
color: #000;
background-color: #fff;
font-size: 18px;
padding: 5px;
}
.tsr_test p {
text-indent: 5px;
margin: 3px;
text-align: center;
}
.tsr_test:hover {
-o-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
transition: all 0.3s ease-in-out;
-o-transform: scale(1.05, 1.05);
-ms-transform: scale(1.05, 1.05);
-moz-transform: scale(1.05, 1.05);
-webkit-transform: scale(1.05, 1.05);
transform: scale(1.05, 1.05);
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.22);
}
<div id="console"></div>
<div class="block">Content</div>
<div class="block">Content</div>
<div class="block">Content</div>
<script>var block_show = null;
function scrollTracking(){
var tsr_id = 67;
var stri = 'tsr_id='+tsr_id;
var wt = $(window).scrollTop();
var wh = $(window).height();
var et = $('#67').offset().top;
var eh = $('#67').outerHeight();
if (et >= wt && et + eh <= wh + wt){
if (block_show == null || block_show == false) {
$.get('/postback/views.php', (stri), function(data) {
console.log(data); // ответ от сервера
});
}
block_show = true;
} else {
block_show = false;
}
}
</script>
<div class="tsr_test">
<a href="">
<div class="image" id=67>
<img src="/img/tsr/5fcf9cfee7383.jpg" alt="">
</div>
<div class="title"><p>
текст
</p></div>
</a>
</div>
<script>var block_show = null;
function scrollTracking(){
var tsr_id = '68';
var stri = 'tsr_id='+tsr_id;
var wt = $(window).scrollTop();
var wh = $(window).height();
var et = $('#68').offset().top;
var eh = $('#68').outerHeight();
if (et >= wt && et + eh <= wh + wt){
if (block_show == null || block_show == false) {
$.get('/postback/views.php', (stri), function(data) {
console.log(data); // ответ от сервера
});
}
block_show = true;
} else {
block_show = false;
}
}
$(window).scroll(function(){
scrollTracking();
});
$(document).ready(function(){
scrollTracking();
});
</script>
<div class="tsr_test">
<a href="" >
<div class="image" id=68>
<img src="/img/tsr/5fcf9cfee7383.jpg" alt="">
</div>
<div class="title"><p>
текст
</p></div>
</a>
</div>
<div class="block">Content</div>
<div class="block">Content</div>
<div class="block">Content</div>