这是HTML。 我试过编辑css但没有结果。 我已经检查了文件夹的位置,一切正常(大文件夹项目和其他文件夹在里面(主页,产品。。。)。他们每个人都有自己的css,类似于你在这里看到的一个。还有一个细节:链接昨天工作,所以错误一定是在css里面!但同时索引链接工作,而其他没有,所以这对我来说没有意义。
<html> <head> </head> <body> <div class="container-fluid"> <div class="row"> <div class="menu-bar"> <ul id="menu"> <div class="col-3"> <li> <a href="index.html" target="_blank"> <img src="img/apewhite.png" width="200%" height="200%"> </a> </li> </div> <div class="col-1 home"> <li> <a class= "menu" href="index.html"target="_blank"> Home </a> </li> </div> <div class="col-1 abt"> <li> <a class= "menu" href="../AboutUs/AboutUs.html"target="_blank"> About us </a> </li> </div> <div class="col-1 prd"> <li> <a class= "menu" href="../products/products.html"target="_blank"> Products </a> </li> </div> <div class="col-2 research"> <li> <a class= "menu" href="../R&D/R&D.html"target="_blank"> Research&Development </a> </li> </div> <div class="col-2 news"> <li> <a class= "menu" href="../News_Events/News_&_Events.html" target="_blank"> News&Events </a> </li> </div> <div class="col-2 contacts"> <li> <a class= "menu" href="../Contacts/contacts.html"target="_blank"> Contacts </a> </li> </div> </ul> </div> </div> </div> </body> </html>
/*THIS IS CSS*/
body {
background-image: url(../img/nanotech.jpg);
background-size: 105%;
background-repeat: no-repeat;
max-width: 105%;
}
.container-fluid
{
width: 105%;
overflow: hidden;
}
.home, .abt, .prd, .research, .news, .contacts {
margin-top: 12px;
}
.home {
margin-left:1.5%;
margin-right: 3%;
}
.abt {
margin-right: 5%;
}
.prd {
margin-right: 4.5%;
}
.research {
margin-right: 5%;
}
.news {
margin-right: -1.5%;
}
.contacts {
}
.menu-bar{
opacity: 0.9;
width: 105%;
float: left;
margin: 0;
padding: 0;
background: #B22222;
}
#menu {
position:relative; /* <- thing I've tried to add */
z-index:1; /* <- thing I've tried to add */
font-family: Verdana, sans-serif;
font-weight: bold;
font-size: 1em;
margin-top: 6px;
margin-right: 0;
margin-left:0;
padding: 0;
list-style: none;
height: 60px;
}
#menu li {
position:relative; /* <- thing I've tried to add*/
z-index:1; /* <- thing I've tried to add */
display: block;
width: 150px;
height: 30px;
margin: 2px;
float: left;/* <- I've tried to get rid of it but the error persists*/
}
ul
{
margin: 0;
padding: 0;
list-style-type: none;
display:inline-flex;
}
a
{
padding: 5px;
color: white;
text-decoration: none;
}
a.menu:link {text-decoration: none}
a.menu:visited {color : white}
a.menu:active {color : white}
a.menu:hover {color: white}
li ul
{
display: none
}
li:hover ul
{
opacity: 90%;
display: block;
position: absolute;
z-index:1;
height:110px;
width:220px;
padding: 5px;
margin-top: 3%;
background: #B22222;
}
#sub {
margin-top:1%;
}
li li { border:none; width:150px; }
li li a { padding:2px 2px 2px 10px; }
../
用于分两步返回目录(文件夹)。 如果您试图访问products.html
目录中名为products.html
的文件,则只需编写products/products.html
即可。
注意,如果这个导航窗格要出现在不同“目录”(文件夹)内的其他页面上,最好使用文件所在位置的完整路径。
另一个建议是始终使用小写(小写字母),这样您的用户在访问您的站点时就不会出错。
希望这能有所帮助,欢迎来到StackOverflow!
如果您的index.html与其他文件夹位于同一目录中,则无需在路径开始处添加..
双点,甚至/
斜杠。 我在想有以下目录树吗
index.html
|-Aboutus
|-aboutus.html
|-products
|-products.html
null
body {
background-image: url(../img/nanotech.jpg);
background-size: 105%;
background-repeat: no-repeat;
max-width: 105%;
}
.container-fluid
{
width: 105%;
overflow: hidden;
}
.home, .abt, .prd, .research, .news, .contacts {
margin-top: 12px;
}
.home {
margin-left:1.5%;
margin-right: 3%;
}
.abt {
margin-right: 5%;
}
.prd {
margin-right: 4.5%;
}
.research {
margin-right: 5%;
}
.news {
margin-right: -1.5%;
}
.contacts {
}
.menu-bar{
opacity: 0.9;
width: 105%;
float: left;
margin: 0;
padding: 0;
background: #B22222;
}
#menu {
position:relative; /* <- thing I've tried to add */
z-index:1; /* <- thing I've tried to add */
font-family: Verdana, sans-serif;
font-weight: bold;
font-size: 1em;
margin-top: 6px;
margin-right: 0;
margin-left:0;
padding: 0;
list-style: none;
height: 60px;
}
#menu li {
position:relative; /* <- thing I've tried to add*/
z-index:1; /* <- thing I've tried to add */
display: block;
width: 150px;
height: 30px;
margin: 2px;
float: left;/* <- I've tried to get rid of it but the error persists*/
}
ul
{
margin: 0;
padding: 0;
list-style-type: none;
display:inline-flex;
}
a
{
padding: 5px;
color: white;
text-decoration: none;
}
a.menu:link {text-decoration: none}
a.menu:visited {color : white}
a.menu:active {color : white}
a.menu:hover {color: white}
li ul
{
display: none
}
li:hover ul
{
opacity: 90%;
display: block;
position: absolute;
z-index:1;
height:110px;
width:220px;
padding: 5px;
margin-top: 3%;
background: #B22222;
}
#sub {
margin-top:1%;
}
li li { border:none; width:150px; }
li li a { padding:2px 2px 2px 10px; }
<html>
<head>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="menu-bar">
<ul id="menu">
<div class="col-3">
<li>
<a href="index.html" target="_blank"> <img src="img/apewhite.png" width="200%" height="200%"> </a>
</li>
</div>
<div class="col-1 home">
<li>
<a class= "menu" href="index.html"target="_blank"> Home </a>
</li>
</div>
<div class="col-1 abt">
<li>
<a class= "menu" href="AboutUs/AboutUs.html"target="_blank"> About us </a>
</li>
</div>
<div class="col-1 prd">
<li>
<a class= "menu" href="products/products.html"target="_blank"> Products </a>
</li>
</div>
<div class="col-2 research">
<li>
<a class= "menu" href="R&D/R&D.html"target="_blank"> Research&Development</a>
</li>
</div>
<div class="col-2 news">
<li>
<a class= "menu" href="News_Events/News_&_Events.html" target="_blank"> News&Events </a>
</li>
</div>
<div class="col-2 contacts">
<li>
<a class= "menu" href="Contacts/contacts.html"target="_blank"> Contacts </a>
</li>
</div>
</ul>
</div>
</div>
</div>
</body>
</html>