gpt4 book ai didi

html - 如何删除响应式导航栏中的空间?

转载 作者:行者123 更新时间:2023-11-28 02:32:59 24 4
gpt4 key购买 nike

我正在尝试创建响应式管理面板。我在每个侧边菜单上方都有一个元素

<a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;Sales Reports</a> 

我希望通过最小化侧边栏变得不可见并且这两个元素出现。它有效,但我无法删除它们之间的空格。我该怎么做?

注意:我愿意接受各种建议和改进。

Fiddle Link

body {
font-family: 'Exo 2', sans-serif;
}

.nav-sidebar {
margin: 80px -20px 20px 20px;
}

.nav-sidebar>li>a {
padding: 20px 20px;
}

.main {
margin-top: 50px;
padding: 20px;
}

.placeholders {
margin-top: 10px;
margin-bottom: 30px;
}

.placeholder {
margin-bottom: 20px;
text-align: center;
}

.placeholder img {
display: inline;
border-radius: 50%;
}

a.icon {
display: none;
}

@media screen and (max-width: 600px) {
.sidebar ul {
max-height: 0;
display: none;
font-size: 0px;
}
.sidebar ul li {
width: 100%;
}
a.icon {
display: block;
visibility: none;
margin-top: 100px;
padding-left: 10px;
}
}
<link rel="stylesheet" media="screen" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css">

<title>Your Own Admin</title>

<link rel="stylesheet" href="css/adminStyle.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Exo+2" rel="stylesheet">

<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;Sales Reports</a>
<ul class="nav nav-sidebar" id="myTopnav">
<li class="active"><a href="#">Sales Reports</a></li>
<li><a href="#">Stats</a></li>
<li><a href="#">Graphs</a></li>
<li><a href="#">Users</a></li>

</ul>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;Performance Reports</a>
<ul class="nav nav-sidebar">
<li class="active"><a href="#">Performance Reports</a></li>
<li><a href="#">Revenue</a></li>
<li><a href="#">Countries</a></li>
<li><a href="#">Spamers</a></li>

</ul>

</div>
<div class="col-sm-9 col-md-10 main">
<h1 class="page-header"><i class="fa fa-tachometer" aria-hidden="true"></i> Dashboard
</h1>
<div class="row placeholders">
<div class="col-xs-6 col-sm-3 placeholder">
<img src="images/graph.png" class="img-responsive" width="200" height="200" alt="">
<h4>Label</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img src="images/graph.png" class="img-responsive" width="200" height="200" alt="">
<h4>Label</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img src="images/graph.png" class="img-responsive" width="200" height="200" alt="">
<h4>Label</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="col-xs-6 col-sm-3 placeholder">
<img src="images/graph.png" class="img-responsive" width="200" height="200" alt="">
<h4>Label</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
<h2 class="sub-header">Detailed Result</h2>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID#</th>
<th>Detail 1#</th>
<th>Detail 2#</th>
<th>Detail 3#</th>
<th>Detail 4#</th>
</tr>
</thead>
<tbody>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
<tr>
<td>234</td>
<td>John</td>
<td>Pentesting</td>
<td>China</td>
<td>90$</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

最佳答案

如果我很好地理解了您的问题,您想要移除两个侧边栏之间的空白空间并保留第一个侧​​边栏的空白空间。

https://jsfiddle.net/1k9sjkeb/12/

.nav-top-sidebar {
margin: 80px -20px 20px 20px; /* You can change the value of the first top margin to move the sidebar to where you want */
}


.nav-sidebar{
margin: 0px -20px 20px 20px;
}

并更改第一个侧边栏的类

<div class="col-sm-3 col-md-2 sidebar">
<a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;Sales Reports</a>
<ul class="nav nav-top-sidebar" id="myTopnav">
<li class="active"><a href="#">Sales Reports</a></li>
<li><a href="#">Stats</a></li>
<li><a href="#">Graphs</a></li>
<li><a href="#">Users</a></li>

</ul>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;Performance Reports</a>
<ul class="nav nav-sidebar">
<li class="active"><a href="#">Performance Reports</a></li>
<li><a href="#">Revenue</a></li>
<li><a href="#">Countries</a></li>
<li><a href="#">Spamers</a></li>

</ul>

这应该可以解决问题:)

关于html - 如何删除响应式导航栏中的空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49348473/

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