gpt4 book ai didi

javascript - 垂直滚动时如何使中心图像变大?

转载 作者:可可西里 更新时间:2023-11-01 14:49:55 28 4
gpt4 key购买 nike

我的页面中有很多圆形图片。当我垂直滚动时,无论我页面中的中心图像是什么,它都应该像图中所示那样缩放。我不知道该怎么做。所以我不会发布任何 jsfiddle。

enter image description here

最佳答案

<html>
<head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<style>
#spacer{height:1000px;}
#content{overflow-y:scroll;height:100%;width:100%;background:white;}
</style>
</head>
<body bgcolor="#fff">
<div id="content">

<div id="spacer"><!--other images --></div>

<img src="lock.png" class="images" id="firstimage"><br><br><img src="lock.png" class="images" id="secondimage"><br><br><img src="lock.png" class="images" id="thirdimage">

<div id="spacer"><!--other images --></div>

<span id="positionvalueboard" style="position:fixed;right:0px;top:0px;"><!--the position (from top) value (in %) to be displayed --></span>

<script>

$(document).ready(function(){
var repeataction= function() {
var height=$(window).height(); /*WINDOW HEIGHT */
var position=$("#firstimage").position(); /*POSITION OF THE IMAGE */
var percent=position.top/height*100; /*CALCULATION OF PERCENTAGE */

$("#positionvalueboard").text(percent); /*CAN BE REMOVED IF NOT NEEDED */
$("#firstimage").height(percent*2); /* FOR THE 1st HALF ('*x' size increased x times) */

if(percent>50){$("#firstimage").height((100-percent)*2 )}; /* FOR THE 2nd HALF ('*x' size increased x times) */
};
var timeOut= setInterval(repeataction, 1); /* USED TO REPEAT THE ACTION */
});
</script>
<script>
$(document).ready(function(){
var repeataction= function() {
var height=$(window).height(); /*WINDOW HEIGHT */
var position=$("#secondimage").position(); /*POSITION OF THE IMAGE */
var percent=position.top/height*100; /*CALCULATION OF PERCENTAGE */

$("#secondimage").height(percent*2); /* FOR THE 1st HALF ('*x' size increased x times) */

if(percent>50){$("#secondimage").height((100-percent)*2 )}; /* FOR THE 2nd HALF ('*x' size increased x times) */
};
var timeOut= setInterval(repeataction, 1); /* USED TO REPEAT THE ACTION */
});
</script>
<script>
$(document).ready(function(){
var repeataction= function() {
var height=$(window).height(); /*WINDOW HEIGHT */
var position=$("#thirdimage").position(); /*POSITION OF THE IMAGE */
var percent=position.top/height*100; /*CALCULATION OF PERCENTAGE */

$("#thirdimage").height(percent*2); /* FOR THE 1st HALF ('*x' size increased x times) */

if(percent>50){$("#thirdimage").height((100-percent)*2 )}; /* FOR THE 2nd HALF ('*x' size increased x times) */
};
var timeOut= setInterval(repeataction, 1); /* USED TO REPEAT THE ACTION */
});
</script>
</div>


</body>

</html>

这会起作用。

关于javascript - 垂直滚动时如何使中心图像变大?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21477581/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com