jquery - jquery侧边栏动画切换弹出窗口
问题描述
再会!
我在左侧有一个侧边栏导航,当有人单击导航链接时,它会切换右侧的显示。但是我怎样才能显示细节并像这样为细节设置动画。
https://codepen.io/jericoborja20/pen/LYbaWVz
这是CSS:
.myDIV {
margin-left: 200px;
font-size: 20px;
padding: 0px 10px;
}
.active {
background-color: green;
color: white;
}
.hide {
display: block;
position: absolute;
width: 100%;
top: 0; left: 0;
bottom: 0; right: 0;
transition: left 1s;
overflow: hidden;
}
.show {
display: block;
position: absolute;
width: 100%;
top: 0; left: 100%;
bottom: 0; right: 0;
transition: left 1s;
overflow: hidden;
}
这是我的javascript函数:
function myFunction() {
var s = document.getElementById('myDIV');
if (s.classList.contains('show')) {
s.classList.remove("show");
s.classList.add("hide");
} else {
s.classList.remove("show");
s.classList.add("hide");
}
}
这是我的 HTML 代码:
<div class="sidenav">
<a href="#about" id="show" onclick="myFunction()">About</a>
</div>
<div class="myDIV">
<h2>Sidebar Dropdown</h2>
<p>Click on the dropdown button to open the dropdown menu inside the side navigation.</p>
<p>This sidebar is of full height (100%) and always shown.</p>
<p>Some random text..</p>
</div>
解决方案
推荐阅读
- google-sheets - 如何在桌面工作表中链接 Google 工作表?
- python - Django order by a field from a related model 返回重复的对象
- docker - dotnet 集成测试在 docker-compose 中找不到服务
- reactjs - 在 AgGrid React 中加载时自动调整大小
- deep-learning - RuntimeError:mat1 和 mat2 形状不能相乘(28x28 和 784x64)
- draftjs - 主题标签建议工作'react-draft-wysiwyg'
- linux - 如何解决:文件/目录已安装但未在任何软件包中提供:
- flutter - 如何从 StreamBuilder 将数据正确保存到我的模型中
- webpack - Webpack 5assetModuleFilename 避免文件名中出现非法字符
- wiremock - Wiremock 快照/编辑快照 URL