我设计了一个包含许多小图像的页面,我喜欢点击小图像然后打开一个固定的div并显示我的大图像,它的工作非常适合在页面上方但滚动下拉到底部时的图像它现在运作良好,什么是真正的
function LoadShowDiv () {
$('.BackgroudShade').slideDown(800); // shade of background will be visible
$(".DivOfImage").show(); // Div of Large Image will be visible
// When Image loaded successful then set width,height and top,left of Large Image Div
// but i want set top,left when screen is scroll down to bottom of page
// then show Div at middle of screen in every time
$('.LargeImage').load(function() {
$('.DivOfImage').width($('.LargeImage').width());
$('.DivOfImage').height($('.LargeImage').height());
var LeftPostion = (WidthOfScreen - $('.LargeImage').width()) / 2;
var TopPostion = (HeightOfScreen - $('.LargeImage').height()) / 2;
$(".DivOfImage").offset({ top: TopPostion, left: LeftPostion});
$('.LargeImage').show(1000);
})
}
$('#SmallImage').click(function(){
$('.LargeImage').attr('src','LargeImage.jpg');
LoadShowDiv();
})
.DivOfImage {
border: 8px solid #FFF;
color:#FFF;
background-color:#FFF;
border-radius:10px;
position:fixed;
}
HTML CODE:
<!-- This is Div of small Image -->
<div class="Image_DIV" id="Image20">
<table>
<tr><td class="Image"><img src="Chosen/Small/20.jpg"/></td></tr>
<tr>
<td class="ImageDescribe"></td></tr>
</table>
</div>
<!-- This is Div of Large Image and Background Shade -->
<div class="BackgroudShade"></div>
<div class="DivOfImage"><img class="LargeImage"/></div>
答案 0 :(得分:0)
从position:fixed;
仅使用css
中删除position:absolute;
,
.DivOfImage {
border: 8px solid #FFF;
color:#FFF;
background-color:#FFF;
border-radius:10px;
position:absolute;// use absolute only
}
在Fixed
之后使用Absolute
覆盖您的position property
,但不会absolute