我在嘗試弄清楚如何爲我的網站設置背景圖片時遇到問題,而不會影響我的導航欄。看起來像圖像喜歡爲我的導航欄顯示。這似乎是我的導航欄上有我的CSS問題?我對HTML/CSS相當新,所以任何幫助將不勝感激:)。顯示在NavBar下的背景圖片
html {
background: url(background-image.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
/* TOP-NAV CSS */
.navbar {
margin: 0 auto;
padding: 0;
font-family: 'Roboto', sans-serif;
font-weight: 400;
line-height: 1.43;
color: #484848;
overflow-x: hidden;
}
.top-nav {
position: relative;
width: 100%;
height: auto;
border-bottom: 1px solid #ccc;
}
.logo:link {
position: relative;
color: #484848;
display: inline-block;
transition: all 0.3s ease;
-webkit-transition: all 0.3s ease; /*Chrome/Opera/Safari */
-moz-transition: all 0.3s ease; /* Firefox */
-ms-transition: all 0.3s ease; /* IE */
}
.logo:visited {
color: #484848;
}
.logo:hover {
background-color: #f1f1f1;
}
/* Image Logo */
.logo img {
position: relative;
padding: 16px 19px;
width: 100px;
border-right: 1px solid #ccc;
vertical-align: middle;
}
/* NAV-SEARCH CSS */
#nav-search-wrapper {
display: inline-block;
width: 490px;
height: 100%;
}
/* Search Bar Form */
#nav-search-wrapper form input {
padding: 18px 10px 18px 52px;
width: 100%;
border: none;
outline: none;
color: #666;
font-size: 14px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
background-image: url('search-icon.svg');
background-repeat: no-repeat;
background-position: 25px;
background-size: 18px;
}
<div class="navbar navbar-default navbar-fixed-top">
<header>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalabe=no" />
<link rel="stylesheet" type="text/css" href="header.css" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet" />
<div class="top-nav clearfix">
<a href="" class="logo">
<img src="" class="logo"/>
</a>
<div id="nav-search-wrapper">
<form method="GET" action="">
<input type="text" name="search" id="nav-search" placeholder="Search" />
</form>
</div>
<ul>
<li><a href="">Ticket Form</a></li>
<li><a href="">Locations</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Sign Up</a></li>
</ul>
</div>
</header>
</div>
看看你的'.navbar'類。它只是沒有背景屬性 – DestinatioN
也許嘗試爲你的'.navbar'類設置一個'background-color:white'? – melvindidit
我嘗試將背景色設置爲某種顏色,但它仍然有圖像與我的導航欄重疊。 – archeryninja