jQuery使用hide()、toggle()函数实现相机品牌展示隐藏功能
(编辑:jimmy 日期: 2025/10/26 浏览:3 次 )
最近在学习jQuery时接触到了show()、hide()、toggle()函数,于是利用这几个函数练习了一个使元素显示隐藏的案例:
小提示:代码中切换按钮上下的小图标可以在此链接品牌展示功能图片中获取
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>使用hide()、toggle()函数实现相机品牌展示</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
font-size: 12px;
text-align: center;
}
a {
color: #04D;
text-decoration: none;
}
a:hover {
color: #F50;
/*text-decoration 属性规定添加到文本的修饰,下划线、上划线、删除线等。*/
text-decoration: underline;
}
.SubCategoryBox {
width: 600px;
margin: 0 auto;
text-align: center;
margin-top: 40px;
}
.SubCategoryBox ul {
list-style: none;
}
.SubCategoryBox ul li {
display: block;
float: left;
width: 200px;
line-height: 20px;
}
.showmore, .showless {
clear: both;
text-align: center;
padding-top: 10px;
}
.showmore a, .showless a {
display: block;
width: 120px;
margin: 0 auto;
line-height: 24px;
border: 1px solid #AAA;
}
.showmore a span {
padding-left: 15px;
/*最后两位数字是以左上角为(0,0)的坐标做一个偏移
第一个数字是X轴上的偏移量,也就是横向的偏移量,正表示向右,负表示向左!
第二个数字是Y轴上的偏移量,也就是横向的偏移量,正表示向下,负表示向上!*/;
background: url(img/down.gif) no-repeat 0 3px;
}
.showless a span {
padding-left: 15px;
background: url(img/up.gif) no-repeat 0 3px;
}
.promoted a {
color: #F50;
}
</style>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.min.js">
代码运行效果:
功能展示效果:
下一篇:vue穿梭框实现上下移动

