<!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>
/*给父元素一个透视*/
body {
perspective: 800px;
}
* {
margin: 0;
padding: 0;
}
div {
width: 100px;
background-color: rgb(169, 115, 115);
}
div li {
height: 100px;
}
div li:nth-child(1) {
background-color: rgb(141, 214, 115);
}
div li:nth-child(2) {
background-color: rgb(6, 72, 40);
}
div li:nth-child(3) {
background-color: rgb(52, 166, 237);
}
div li:nth-child(4) {
background-color: rgb(167, 22, 211);
}
div:hover+section {
transform: rotateY(0deg);
}
section {
position: absolute;
top: 0;
width: 300px;
height: 200px;
margin-left: 100px;
transform-style: preserve-3d;
transform: rotateY(180deg);
/* 改变转轴位置 */
transform-origin: 0% 100%;
background-color: rgb(192, 25, 25);
transition: all 2s;
z-index: -1;
}
</style>
</head>
<body>
<div>
<ul>
<li>菜单</li>
<li>首页</li>
<li>菜单</li>
<li>首页</li>
</ul>
</div>
<section>
</section>
<script>
let lis = document.querySelectorAll('li')
let s = document.querySelector('section')
for (let i = 0; i < lis.length; i++) {
lis[i].onmouseover = function() {
s.innerHTML = lis[i].innerText
}
}
</script>
</body>
</html>
旋转折叠侧边导航栏
最新推荐文章于 2022-11-19 23:15:01 发布