温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用Jquery和CSS折叠图像

发布时间:2021-08-07 20:39:57 来源:亿速云 阅读:150 作者:chen 栏目:web开发

这篇文章主要介绍“如何使用Jquery和CSS折叠图像”,在日常操作中,相信很多人在如何使用Jquery和CSS折叠图像问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何使用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
<div class="imagebox" style="max-height:100px;">
<img src="image.jpg"/>
<div class="showhide" >
<a href="#" class="showlink">show</a>
<a href="#" class="hidelink">hide</a>
</div>
</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%;
}

到此,关于“如何使用Jquery和CSS折叠图像”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI