左侧菜单添加滚动条

javascript部分代码:

$(function(){
    
    
	var  menuHeight = document.getElementById('menu');// menu 菜单ul的id名称
    var  screenHeight = window.innerHeight  //浏览器窗口的内部高度
    menuHeight.style.height=screenHeight-80+"px";
    $("#menu").css({
    
    "overflow-y":"auto","height":menuHeight});//添加滚动条并设置滚动条高度(根据屏幕自适应)
	})

html部分代码:

<ul  id="menu">
<li>1111</li>
<li>2222</li>
<li>3333</li>
<li>4444</li>
</ul>

猜你喜欢

转载自blog.csdn.net/w15562397578/article/details/106516804
今日推荐