繁体   English   中英

图片隐藏和显示不起作用

[英]Image hide and show not working

我正在使用此jquery.smoothZoom.min.js缩放和平移图像。我已将其成功应用于我的项目中的单个图像,现在我想添加(<,>。ie corousal),以便将其用于多张图片。当我在custom.js中添加相应的部分时,它无法正常工作。

我将附加两个屏幕种类以清除图片

这是第一种情况 在此处输入图片说明

然后单击右侧的珊瑚按钮

在此处输入图片说明

我只能看到背景,而看不到所需的图像。 我不明白我在想什么,

这是我一直在使用的html部分

    <div class="image-display" id="displayplan4" style="width:70%;height:120%; left:39%;top:10%;position:absolute;display:none;"> 

        <img src="images/amenities.jpg" style="width:150%;height:130%; left:-60%;top:-20%;position:absolute;overflow:auto; z-index:1;">
        <div style="width:150%;height:130%; left:-60%;top:-20%;position:absolute;background:rgba(255,255,255,0.7);z-index:2;">
        </div>

        <img class="planzoom" src="gallery/Residential/ongoing/Almog/Plan/almog1.jpg" id = "almogplan0" style="width:100%;height:100%; right:3%;top:50%;position:absolute;z-index:3;">
                    <!--button for forward and backward movement-->
            <a href="#" > <img src="innerimages/forward.gif" id="almogforward" style="position:absolute;height:3%;width:2%;z-index:3;top:25%;right:20%;"></a>
            <a href="#" ><img src="innerimages/back.gif"     id="almogback"    style="position:absolute;height:3%;width:2%;z-index:3;top:25%;left:0%;"></a>
    </div>

<div id = "almogplandivII">
            <img class="planzoom" src="gallery/Residential/ongoing/Almog/Plan/almog2.jpg" id= "almogplan1" style="width:100%;height:100%; right:3%;top:50%;position:absolute;z-index:3;display:none;">      
        </div>

以及相应的js部分,可通过鼠标单击图像来显示和隐藏图像。

var almog_plan_div=0;

//Function for image forward with forward button
$("#almogforward").click(function () 
{
    if(almog_plan_div<1)
    {
        $("#almogplan"+almog_plan_div).hide();
        almog_plan_div++;
        $("#almogplan"+almog_plan_div).show();
    }
    else
    {
        $("#almogplan"+almog_plan_div).hide();
        almog_plan_div=0;
        $("#almogplan"+almog_plan_div).show();
    }
}); 

//Function for image backward with backward button
$("#almogback").click(function () 
{ 
    if(almog_plan_div>0)
    {
        $("#almogplan"+almog_plan_div).hide();
        almog_plan_div--;
        $("#almogplan"+almog_plan_div).show();
    }
    else
    {
        $("#almogplan"+almog_plan_div).hide();
        almog_plan_div=1;
        $("#almogplan"+almog_plan_div).show();
    }
});

我已经尝试过像添加display:none样式属性一样,但这对我的事业没有帮助,对此有任何帮助吗?

删除内联样式显示:从img标签中删除任何内容,然后在初始化页面时,使用hide()函数隐藏该图像。

内联样式可能会覆盖此问题

感谢您的两个回答,你们俩可能都不完全正确,但绝对可以帮助我获得解决方案。

我不知道的把戏:

我)使用了两个不同的div,但是我没有定位第二个div,(我只注意到当我在其中只有2张图像的新网页中尝试整个操作时,它们的位置不正确)我的需求需要div要隐藏,我不得不将它们隐藏。

2)我必须删除的另一件事是position:absolute来自单个图像元素的position:absolute内容。 一旦纠正它现在很酷。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM