我有两个粘性的导航栏。问题是它们都在页面的左上角相交,侧面导航栏与顶部导航栏相交,阻止了按钮。我尝试过填充填充物,但是两个导航条相交的地方仍然存在一个看不见的空间。我想做的是,在顶栏下面有侧栏,它们不相交并阻挡按钮的一部分。到目前为止,这是我的代码:
.button {
display: inline-block;
border-radius: 4px;
background-color: #4CAF50e;
border: none;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
body {margin:10}
.icon-bar {
height: 100%;
width: 90px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #555;
overflow-x: hidden;
padding-top: 0px;
}
.icon-bar a {
text-align: center;
padding: 6px 8px 6px 16px;
transition: all 0.3s ease;
text-decoration: none;
font-size: 36px;
color: #white;
display: block;
}
.icon-bar a:hover {
background-color: #4289b5;
}
.active {
background-color: #4CAF50 !important;
}
.mainsbar {
margin-left: 160px; /* Same as the width of the sidenav */
font-size: 28px; /* Increased text to enable scrolling */
padding: 0px 10px;
}
@media screen and (max-height: 450px) {
.icon-bar {padding-top: 15px;}
.icon-bar a {font-size: 18px;}
}
body{
font-size: 20px;
font-family: Roboto;
font-weight: 300;
}
a{
text-decoration: none;
;
padding: 10px 15px;
line-height: 3;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
a:hover{
color: #FFF;
background: #FC2121;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
body {margin:0;}
.icon-bartop {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
background-color: #555;
overflow: auto;
}
.icon-bartop a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 20px;
}
.icon-bartop a:hover {
background-color: #000;
}
.active {
background-color: #4CAF50 !important;
}
.main {
padding: 0px;
margin-top: 80px;
height: 1500px; /* Used in this example to enable scrolling */
}
<!DOCTYPE html>
<html>
<body>
<html lang="en">
<head>
<title>Web Scraper</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/scripts.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body style="background-color:#7f8fa8;">
<div class="main">
<div class="icon-bartop">
<a href="#"><i class="fa fa-home"></i></a>
<a href="#news"><i class="fa fa-newspaper"></i></a>
<a href="#"><i class="fa fa-envelope"></i></a>
<a href="#"><i class="fa fa-globe"></i></a>
<a href="#"><i class="fa fa-trash"></i></a>
</div>
<div id="home">
<div class="sidebar">
<meta name="viewport" content="width=device-width, initial-scale=1">
<div class="icon-bar">
<a class="active" href="#search"><i class="fa fa-search"></i></a>
<a href="javascript:getPrices();"><i class="fa fa-bitcoin"></i></a>
<a href="https://www.google.com/maps/"><i class="fa fa-map"></i></a>
<a href="https://www.wolframalpha.com/"><i class="fa fa-anchor"></i></a>
<a href="https://www.amazon.com/"><i class="fa fa-shopping-cart"></i></a>
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
<!-- Search Form -->
</div>
<div id="news">
<h1 align="center">Test</h1>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
console.log('Loading')
.button {
display: inline-block;
border-radius: 4px;
background-color: #4CAF50e;
border: none;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
body {margin:10}
.icon-bar {
height: 100%;
width: 90px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #555;
overflow-x: hidden;
margin-top: 83px;
}
.icon-bar a {
text-align: center;
padding: 6px 8px 6px 16px;
transition: all 0.3s ease;
text-decoration: none;
font-size: 36px;
color: #white;
display: block;
}
.icon-bar a:hover {
background-color: #4289b5;
}
.active {
background-color: #4CAF50 !important;
}
.mainsbar {
margin-left: 160px; /* Same as the width of the sidenav */
font-size: 28px; /* Increased text to enable scrolling */
padding: 0px 10px;
}
@media screen and (max-height: 450px) {
.icon-bar {padding-top: 15px;}
.icon-bar a {font-size: 18px;}
}
body{
font-size: 20px;
font-family: Roboto;
font-weight: 300;
}
a{
text-decoration: none;
;
padding: 10px 15px;
line-height: 3;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
a:hover{
color: #FFF;
background: #FC2121;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
body {margin:0;}
.icon-bartop {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
background-color: #555;
overflow: auto;
}
.icon-bartop a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 20px;
}
.icon-bartop a:hover {
background-color: #000;
}
.active {
background-color: #4CAF50 !important;
}
.main {
padding: 0px;
margin-top: 80px;
height: 1500px; /* Used in this example to enable scrolling */
}
<!DOCTYPE html>
<html>
<body>
<html lang="en">
<head>
<title>Web Scraper</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/scripts.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body style="background-color:#7f8fa8;">
<div class="main">
<div class="icon-bartop">
<a href="#"><i class="fa fa-home"></i></a>
<a href="#news"><i class="fa fa-newspaper"></i></a>
<a href="#"><i class="fa fa-envelope"></i></a>
<a href="#"><i class="fa fa-globe"></i></a>
<a href="#"><i class="fa fa-trash"></i></a>
</div>
<div id="home">
<div class="sidebar">
<meta name="viewport" content="width=device-width, initial-scale=1">
<div class="icon-bar">
<a class="active" href="#search"><i class="fa fa-search"></i></a>
<a href="javascript:getPrices();"><i class="fa fa-bitcoin"></i></a>
<a href="https://www.google.com/maps/"><i class="fa fa-map"></i></a>
<a href="https://www.wolframalpha.com/"><i class="fa fa-anchor"></i></a>
<a href="https://www.amazon.com/"><i class="fa fa-shopping-cart"></i></a>
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
<!-- Search Form -->
</div>
<div id="news">
<h1 align="center">Test</h1>
</div>
</div>
</body>
</html>
使用margin-top
代替padding-top
。
答案 1 :(得分:1)
尝试更改top
的值.icon-bar {
height: 100%;
width: 90px;
position: fixed;
z-index: 1;
top: 84px;
left: 0;
background-color: #555;
overflow-x: hidden;
padding-top: 0px;
}
答案 2 :(得分:1)
您可以将您的顶部位置设置为84px ...因为您使用的是固定位置,您可以使用cal()来计算您的身高。
console.log('Loading')
&#13;
.button {
display: inline-block;
border-radius: 4px;
background-color: #4CAF50e;
border: none;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
body {margin:10}
.icon-bar {
height: calc(100% - 84px);
width: 90px;
position: fixed;
z-index: 1;
top: 84px;
left: 0;
background-color: #555;
overflow-x: hidden;
padding-top: 0px;
}
.icon-bar a {
text-align: center;
padding: 6px 8px 6px 16px;
transition: all 0.3s ease;
text-decoration: none;
font-size: 36px;
color: #white;
display: block;
}
.icon-bar a:hover {
background-color: #4289b5;
}
.active {
background-color: #4CAF50 !important;
}
.mainsbar {
margin-left: 160px; /* Same as the width of the sidenav */
font-size: 28px; /* Increased text to enable scrolling */
padding: 0px 10px;
}
@media screen and (max-height: 450px) {
.icon-bar {padding-top: 15px;}
.icon-bar a {font-size: 18px;}
}
body{
font-size: 20px;
font-family: Roboto;
font-weight: 300;
}
a{
text-decoration: none;
;
padding: 10px 15px;
line-height: 3;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
a:hover{
color: #FFF;
background: #FC2121;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
body {margin:0;}
.icon-bartop {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
background-color: #555;
overflow: auto;
}
.icon-bartop a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 20px;
}
.icon-bartop a:hover {
background-color: #000;
}
.active {
background-color: #4CAF50 !important;
}
.main {
padding: 0px;
margin-top: 80px;
height: 1500px; /* Used in this example to enable scrolling */
}
&#13;
<!DOCTYPE html>
<html>
<body>
<html lang="en">
<head>
<title>Web Scraper</title>
<script src="https://cdn.jsdelivr.net/npm/sweetalert"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/scripts.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body style="background-color:#7f8fa8;">
<div class="main">
<div class="icon-bartop">
<a href="#"><i class="fa fa-home"></i></a>
<a href="#news"><i class="fa fa-newspaper"></i></a>
<a href="#"><i class="fa fa-envelope"></i></a>
<a href="#"><i class="fa fa-globe"></i></a>
<a href="#"><i class="fa fa-trash"></i></a>
</div>
<div id="home">
<div class="sidebar">
<meta name="viewport" content="width=device-width, initial-scale=1">
<div class="icon-bar">
<a class="active" href="#search"><i class="fa fa-search"></i></a>
<a href="javascript:getPrices();"><i class="fa fa-bitcoin"></i></a>
<a href="https://www.google.com/maps/"><i class="fa fa-map"></i></a>
<a href="https://www.wolframalpha.com/"><i class="fa fa-anchor"></i></a>
<a href="https://www.amazon.com/"><i class="fa fa-shopping-cart"></i></a>
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
<!-- Search Form -->
</div>
<div id="news">
<h1 align="center">Test</h1>
</div>
</div>
</body>
</html>
&#13;