使用Jquery和CSS折叠图像

发布时间:2025-08-31 20:23:52 作者:益华网络 来源:undefined 浏览量(0) 点赞(0)
摘要:如何使用Jquery和CSS进行折叠图像。

如何使用Jquery和CSS进行折叠图像。 Orkut.com 在更新图像碎片时实现了这个概念,碎片以折叠样式显示图像以减少网页高度。 这是使用mouseover,mouseout和css Jquery函数的非常简单的脚本。

Javascript 代码 包含javascipt和HTML代码。 $(“。imagebox”)。mouseover(function(){})。mouseout(function {})  - imagebox是div标签的类名。 $(“。showlink”)。click(function(){})  - .showlink是show anchor tag的类名。 $(“。hidelink”)。click(function(){})  - .hidelink是隐藏锚标记的类名。 使用Jquery CSS函数chaning  max-height:100px

<script  type=" text/javascript " src=" http://ajax.googleapis.com/ ajax/libs/jquery/1.4.2/jquery.min.js " > </script> <script  type=" text/javascript " > $(document).ready( function

()

{

// Image Area Mouseover and Mouseout

$(".imagebox"). mouseover ( function

()

{

$(".showhide").show();

}). mouseout ( function

()

$(".showhide").hide();

});

//Show link

$(".showlink").click(function()

{

$(".imagebox").css(max-height,);

$(".showlink").hide();

$(".hidelink").show();

});

//Hide link 

$(".hidelink").click(function()

{

$(".imagebox").css(max-height,100px);

$(".hidelink").hide();

$(".showlink").show();

});

});

</script>

//HTML code

show

hide

</div>

CSS 代码

.imagebox

{

display:block;

position:relative;

overflow:hidden

}

.hidelink

{

display:none;

}

.showhide

{

padding:5px;

border-top:dashed 1px #333;

border-bottom:dashed 1px #333;

background:#F2f2f2 none repeat scroll 0 0;

bottom:0;

cursor:pointer;

display:block;

height:18px;

left:0;

line-height:18px;

padding-left:5px;

position:absolute;

width:100%;

}

二维码

扫一扫,关注我们

声明:本文由【益华网络】编辑上传发布,转载此文章须经作者同意,并请附上出处【益华网络】及本页链接。如内容、图片有任何版权问题,请联系我们进行处理。

感兴趣吗?

欢迎联系我们,我们愿意为您解答任何有关网站疑难问题!

您身边的【网站建设专家】

搜索千万次不如咨询1次

主营项目:网站建设,手机网站,响应式网站,SEO优化,小程序开发,公众号系统,软件开发等

立即咨询 15368564009
在线客服
嘿,我来帮您!