gpt4 book ai didi

javascript - 我如何将侧边栏包装器移动到单杠下方

转载 作者:行者123 更新时间:2023-11-28 03:00:37 25 4
gpt4 key购买 nike

您好,我正在尝试,因为我是 html 和 css 的新手,你们可以建议我如何将侧包装器移动到水平导航栏下方,并且导航栏应适合页面宽度。在水平导航栏中,我有一个名为 home 和 logout 的文本,你们可以移动右端并将其设为主页图标和注销图标吗

fiddle :https://jsfiddle.net/xzm7bx4n/

$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("active");
});
.row{
margin-left:0px;
margin-right:0px;
}

#wrapper {
padding-left: 70px;
transition: all .4s ease 0s;
height: 100%
}

#sidebar-wrapper {
margin-left: -150px;
left: 70px;
width: 200px;
background: #222;
position: fixed;
height: 60%;
z-index: 10000;
transition: all .4s ease 0s;
float:top;
}

.sidebar-nav {
display: block;
float: left;
width: 200px;
list-style: none;
margin: 0;
padding: 0;
}
#page-content-wrapper {
padding-left: 0;
margin-left: 0;
width: 100%;
height: auto;
}
#wrapper.active {
padding-left: 150px;
}
#wrapper.active #sidebar-wrapper {
left: 150px;
}

#page-content-wrapper {
width: 100%;
}

#sidebar_menu li a, .sidebar-nav li a {
color: #999;
display: block;
float: left;
text-decoration: none;
width: 200px;
background: #252525;
border-top: 1px solid #373737;
border-bottom: 1px solid #1A1A1A;
-webkit-transition: background .5s;
-moz-transition: background .5s;
-o-transition: background .5s;
-ms-transition: background .5s;
transition: background .5s;
}
.sidebar_name {
padding-top: 25px;
color: #fff;
opacity: .7;
}

.sidebar-nav li {
line-height: 40px;
text-indent: 20px;
}

.sidebar-nav li a {
color: #999999;
display: block;
text-decoration: none;
}

.sidebar-nav li a:hover {
color: #fff;
background: rgba(255,255,255,0.2);
text-decoration: none;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
height: 65px;
line-height: 60px;
font-size: 18px;
}

.sidebar-nav > .sidebar-brand a {
color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}

#main_icon
{
float:right;
padding-right: 65px;
padding-top:20px;
}
.sub_icon
{
float:right;
padding-right: 65px;
padding-top:10px;
}
.content-header {
height: 65px;
line-height: 65px;
}

.content-header h1 {
margin: 0;
margin-left: 20px;
line-height: 65px;
display: inline-block;
}

@media (max-width:767px) {
#wrapper {
padding-left: 70px;
transition: all .4s ease 0s;
}
#sidebar-wrapper {
left: 70px;
}
#wrapper.active {
padding-left: 150px;
}
#wrapper.active #sidebar-wrapper {
left: 150px;
width: 150px;
transition: all .4s ease 0s;
}
}
<script src="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.js"></script>
<script src="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/vendor/jquery/jquery.min.js"></script>
<link href="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/vendor/metisMenu/metisMenu.min.css" rel="stylesheet"/>
<link href="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<div id="wrapper" class="active">
<!-- Sidebar -->
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav" id="sidebar">
<li><a>New Project</a></li>
<li><a>Projects</a></li>
<li><a>Pyramid Oppurtinities</a></li>
</ul>
</div>

<!-- Page content -->
<div id="page-content-wrapper">
<!-- Keep all page content within the page-content inset div! -->
<div class="page-content inset">
<div class="row">
<div class="col-md-14">
<p class="well lead">SANRIA Home Logout</p>


<div class="container">
<div class="row"> <!-- div da esquerda -->
<!-- Text input CNPJ e Razao Social-->

</div> <!-- fim div da esquerda -->
</div>
<!-- <p class="well lead">An Experiment using the sidebar (<a href="http://animeshmanglik.name">animeshmanglik.name</a>)</p> -->
</div>
</div>
</div>
</div>

最佳答案

很高兴您提出这个问题。当您有一个标题应该是 DOM 中的第一件事时,您希望将它或作为包装器中的第一个元素。侧边栏元素可以放置在它的下方以实现时尚的外观。如果你想要不同的风格,我们也可以讨论。这是我结束的代码。

<div id="wrapper" class="active">  
<!-- Sidebar -->
<!-- Sidebar -->

<!-- Page content -->
<div id="page-content-wrapper">
<!-- Keep all page content within the page-content inset div! -->
<div class="page-content inset">
<div class="row">
<div class="col-md-14">
<p class="well lead">SANRIA Home Logout</p>


<div class="container">
<div class="row"> <!-- div da esquerda -->
<!-- Text input CNPJ e Razao Social-->

</div> <!-- fim div da esquerda -->
</div>
<!-- <p class="well lead">An Experiment using the sidebar (<a href="http://animeshmanglik.name">animeshmanglik.name</a>)</p> -->
</div>
</div>

<div id="sidebar-wrapper">
<ul class="sidebar-nav" id="sidebar">
<li><a>New Project</a></li>
<li><a>Projects</a></li>
<li><a>Pyramid Oppurtinities</a></li>
</ul>
</div>

</div>
</div>

这是 CSS。

.row{
margin-left:0px;
margin-right:0px;
}

#wrapper {
/*padding-left: 70px;*/
transition: all .4s ease 0s;
height: 100%
}

#sidebar-wrapper {
margin-left: -150px;
left: 70px;
width: 200px;
background: #222;
position: fixed;
height: 60%;
z-index: 10000;
transition: all .4s ease 0s;
/*float:top;*/
}

.sidebar-nav {
display: block;
float: left;
width: 200px;
list-style: none;
margin: 0;
padding: 0;
}
#page-content-wrapper {
padding-left: 0;
margin-left: 0;
width: 100%;
height: auto;
}
#wrapper.active {
/*padding-left: 150px;*/
}
#wrapper.active #sidebar-wrapper {
left: 150px;
}

#page-content-wrapper {
width: 100%;
}

#sidebar_menu li a, .sidebar-nav li a {
color: #999;
display: block;
float: left;
text-decoration: none;
width: 200px;
background: #252525;
border-top: 1px solid #373737;
border-bottom: 1px solid #1A1A1A;
-webkit-transition: background .5s;
-moz-transition: background .5s;
-o-transition: background .5s;
-ms-transition: background .5s;
transition: background .5s;
}
.sidebar_name {
padding-top: 25px;
color: #fff;
opacity: .7;
}

.sidebar-nav li {
line-height: 40px;
text-indent: 20px;
}

.sidebar-nav li a {
color: #999999;
display: block;
text-decoration: none;
}

.sidebar-nav li a:hover {
color: #fff;
background: rgba(255,255,255,0.2);
text-decoration: none;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
height: 65px;
line-height: 60px;
font-size: 18px;
}

.sidebar-nav > .sidebar-brand a {
color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}

#main_icon
{
float:right;
padding-right: 65px;
padding-top:20px;
}
.sub_icon
{
float:right;
padding-right: 65px;
padding-top:10px;
}
.content-header {
height: 65px;
line-height: 65px;
}

.content-header h1 {
margin: 0;
margin-left: 20px;
line-height: 65px;
display: inline-block;
}

@media (max-width:767px) {
#wrapper {
/*padding-left: 70px;*/
transition: all .4s ease 0s;
}
#sidebar-wrapper {
left: 70px;
}
#wrapper.active {
/*padding-left: 150px;*/
}
#wrapper.active #sidebar-wrapper {
left: 150px;
width: 150px;
transition: all .4s ease 0s;
}
}

.well{
margin-bottom: 0px;
}
.lead{
margin-bottom: 0px;
}
p{
margin: 0px;
}

工作 JSFiddle:https://jsfiddle.net/eq6bhyg5/

注意:我删除了所有似乎会影响 View 的不必要的填充。我们真的应该使用给我们的空间。如果你想让侧边栏在旁边,页面包括标题在它旁边,相邻。操作:将侧边栏从页面内容包装器中取出。添加 display:inline-block; width:20% 到侧边栏 css。然后将包装器 css 设置为 width: 80%;显示:内联 block ;

关于javascript - 我如何将侧边栏包装器移动到单杠下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46229784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com