c语言添加滚动条,html页面添加左侧滑动菜单与内容部分的滚动条

html + css + jquery

思路:

1、通过jquery的animate方法,实现menu菜单的滑出滑入

2、menu菜单通过relative的设置,将其默认设置到页面左侧不可视区

3、通过点击事件,调用animate,将menu滑出滑入

样式如下:

指定一个固定大小的区域显示的样式如下:

3e32b970534a1dfe215e9b8e53892ce5.png                 

880d75235dd5e91c327e4dc04c0db936.png

代码如下:

0c5217b6973c2cf6ec35e99aef5418b8.png

body {

width: 100vw;

height: 100vh;

padding: 0;

margin: 0;

display: flex;

flex-direction: row;

align-items: center;

justify-content: center;

background: #FFEBCD;

}

body>div {

width: 360px;

height: 640px;

border: 3px groove blanchedalmond;

border-radius: 8px;

background: #f1f1f1;

padding: 5px;

overflow: hidden;

}

.page {

width: 500px;

height: 100%;

display: flex;

flex-direction: row;

position: relative;

left: -140px;

}

.content {

height: 100%;

width: 360px;

display: flex;

flex-direction: column;

}

.content>img {

margin-top: 15px;

margin-left: 10px;

cursor: pointer;

height: 26px;

width: 32px;

}

.content>div {

flex-grow: 1;

overflow: auto;

padding: 5px;

font-size: 2em;

-webkit-overflow-scrolling: touch;

}

.menu {

height: 100%;

width: 120px;

margin-right: 20px;

display: flex;

flex-direction: column;

}

.menu>div {

margin: 5px 0 10px 5px;

a8d82cf93b5bcd01842bf25ad00f7dcd.png

设置自动适应全部网页空间的样子如下:

5d71957c8e27f5a5a39ce188643139a9.png      

d26c579e8aee4a49ff76634b7f6f9ae5.png

07e486bbe1c86a7efd0d52978a1f637d.png

body {

padding: 0;

margin: 0;

width: 100vw;

height: 100vh;

display: flex;

justify-content: center;

align-items: center;

overflow: hidden;

}

.page {

width: 100%;

height: 100%;

overflow: hidden;

}

.container {

position: relative;

left: -200px;

width: calc(100% + 200px);

height: 100%;

display: flex;

flex-direction: row;

}

.menu {

width: 200px;

height: 100%;

background: linear-gradient(white, black);

}

.scroll {

flex-grow:1;

height: 100%;

overflow: auto;

-webkit-overflow-scrolling: touch;

}

.content {

width: 100%;

height: 300%;

background: linear-gradient(black, white);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值