console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.outter {
width: 800px;
border: 2px solid black;
overflow: hidden;
margin: 0 auto;
}
.left {
width: 20%;
height: 500px;
float: left;
background-color: pink;
}
.right {
width: 80%;
height: 500px;
float: left;
background-color:lightyellow;
}
#bar {
width: 30px;
height: 50px;
padding-left: 5px;
background-color: green;
border-bottom-right-radius: 15px;
}
</style>
</head>
<body>
<div class="outter">
<div class="left" id="left">
<ol>
<li>菜单1</li>
<li>菜单2</li>
<li>菜单3</li>
<li>菜单4</li>
<li>菜单5</li>
</ol>
</div>
<div class="right" id="right">
<div id="bar">收起</div>
</div>
</div>
<script>
var bar = document.getElementById("bar");
var left = document.getElementById("left");
var right = document.getElementById("right");
bar.onclick = function (){
if(!left.style.display.match("none")){
left.style.display = "none"
right.style.width = "100%"
bar.innerHTML = "隐藏"
}else{
left.style.display = "block"
right.style.width = "80%"
bar.innerHTML = "收起"
}
}
</script>
</body>
</html>