简单滑动下拉列表

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
* {
padding: 0;
margin: 0;
}
ul {
list-style: none;
}

.wrap {
width: 1000px;
height: 800px;
margin: 100px auto 0;

/*background-image: url(imgs/9.jpg);*/
background-color: skyblue;
padding-left: 100px;
}

.wrap li {
float: left;
width: 280px;
height: 30px;

padding: 10px;

position: relative;
}

.wrap a {
color: black;
text-decoration: none;
display: block;
width: 280px;
/*height: 60px;*/
text-align: center;
line-height: 30px;
color: white;
margin-top: 10px;

 

background-color: blue;
}

.wrap li ul {
position: absolute;
display: none;
}

.wrap img{
padding: 20px 0 0 0;
width: 200px;
height: 180px;
/*margin-top: 20px;*/
margin-left: 40px;


}

.photo1,.photo2{

width: 900px;
height: 800px;
margin-top: -36px;

 

}
.photo1{

background-image: url(imgs/10.jpg);
display: none;
}


.photo2{

background-image: url(imgs/11.jpg);
display: none;
}

</style>
<script src="jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function () {

$(".wrap li").hover(function () {
$(this).children("ul").slideToggle();
});


$(".button1").click(function(){

$(".photo1").toggle();


$(".photo2").hide();

});

$(".button2").click(function(){

$(".photo2").toggle();


$(".photo1").hide();

});


});
</script>
</head>
<body>
<div class="wrap">
<ul>
<li>
<a href="#">静态逗逼图</a>
<ul>
<img src="imgs/1.jpg">
<img src="imgs/2.jpg">
<!-- <li><a href="#">二级菜单3</a></li> -->
</ul>
</li>
<li>
<a href="#">动态逗逼图1</a>
<ul>
<img src="imgs/3.jpg">
<img src="imgs/4.jpg">
<img src="imgs/6.gif">
</ul>
</li><li>
<a href="#">动态逗逼图二</a>
<ul>
<img src="imgs/5.jpg">
<img src="imgs/7.jpg">
<img src="imgs/8.gif">
</ul>
</li>
</ul>
<button type="button" class="button1">切换背景1</button>
<button type="button" class="button2">切换背景2</button>
<!-- <input type="button" class="button1">切换背景1</input> -->
<!-- <input type="button" class="button2">切换背景2</input> -->
<div class="photo1"></div>
<div class="photo2"></div>

</div>
</body>
</html>

转载于:https://www.cnblogs.com/xiaohaishuangyu/p/6020886.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现滑动分页列表,可以使用Vue.js配合一些插件来完成,以下是一些步骤: 1. 安装Vue.js并创建Vue实例; 2. 引入Vue插件vue-infinite-loading,它提供了无限滚动加载数据的功能; 3. 创建一个包含列表数据的组件,使用v-for指令来渲染列表; 4. 在组件中使用vue-infinite-loading的指令,在滚动到底部时自动加载下一页数据; 5. 监听滚动事件,当滚动到底部时触发加载数据; 6. 在组件中使用CSS样式来实现滑动效果。 以下是一个简单的示例代码: ```html <template> <div class="list-container" ref="listContainer"> <div v-for="(item, index) in listData" :key="index" class="list-item">{{ item }}</div> <div v-infinite-loading="loadMore" :infinite-disabled="isLoading" infinite-distance="10%"> <div v-if="isLoading"><i class="fa fa-spinner fa-spin"></i> 加载中...</div> <div v-else><i class="fa fa-arrow-down"></i> 下拉加载更多</div> </div> </div> </template> <script> import InfiniteLoading from 'vue-infinite-loading'; export default { components: { InfiniteLoading, }, data() { return { listData: [], currentPage: 1, isLoading: false, }; }, mounted() { this.loadData(); window.addEventListener('scroll', this.handleScroll); }, methods: { loadData() { // 模拟异步加载数据 this.isLoading = true; setTimeout(() => { for (let i = 0; i < 10; i++) { this.listData.push(`Item ${this.listData.length + 1}`); } this.currentPage++; this.isLoading = false; }, 1000); }, loadMore() { this.loadData(); }, handleScroll() { const container = this.$refs.listContainer; const scrollTop = container.scrollTop; const scrollHeight = container.scrollHeight; const clientHeight = container.clientHeight; if (scrollTop + clientHeight >= scrollHeight) { this.loadData(); } }, }, }; </script> <style> .list-container { height: 300px; overflow-y: scroll; } .list-item { height: 50px; line-height: 50px; border-bottom: 1px solid #eee; } </style> ``` 在上面的示例中,我们使用了vue-infinite-loading插件来实现滑动分页列表的功能。同时,我们还监听了滚动事件,在滚动到底部时触发自动加载下一页数据。通过CSS样式设置了列表的高度和滑动效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值