关于这个话题,人们提出的所有问题都太复杂了,我已经看到了。我试着做一个基本的导航栏,我可以习惯HTML的工作方式。这是我的代码:
myFile.html:
<!DOCTYPE HTML>
<html>
<head>
</head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: inline;
}
a:link, a:visited {
display: block;
width: 120px;
font-weight: bold;
color: white;
background-color: black;
text-align: center;
text-decoration: none;
text-transform: uppercase;
}
a:hover, a:active {
background-color: dark-grey;
}
body {
background-image: url("fallout man and dog.jpg");
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>
<body>
<ul>
<li><a href="file:///E:/HTML folders/Fallout4Test/myFile.html">HOME</a></li>
<li><a href="file:///E:/HTML folders/Fallout4Test/Videos.html">VIDEOS</a></li>
</ul>
<h1>This is the Heading</h1>
</body>
</html>
<!-- file:///C:/Users/tylersong55/Desktop/myFile.html -->Videos.html:
<!DOCTYPE HTML>
<html>
<head>
</head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: inline;
}
a:link, a:visited {
display: block;
width: 120px;
font-weight: bold;
color: white;
background-color: black;
text-align: center;
text-decoration: none;
text-transform: uppercase;
}
a:hover, a:active {
background-color: dark-grey;
}
body {
background-image: url("fallout man and dog.jpg");
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
h2 {
background-color: black;
color: white;
}
</style>
<body>
<ul>
<li><a href="file:///E:/HTML folders/Fallout4Test/myFile.html">HOME</a></li>
<li><a href="file:///E:/HTML folders/Fallout4Test/Videos.html">VIDEOS</a></li>
</ul>
<h2>Fallout 4 - Announcement Trailer</h2>
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/XW7Of3g2JME"
frameborder="0" allowfullscreen></iframe></center>
<h2>Fallout 4 - The Wanderer Trailer</h2>
<center><iframe width="560" height="315" src="https://www.youtube.com/embed/k3IlHBBGCIw"
frameborder="0" allowfullscreen></iframe></center>
</body>
</html>我让它在一个点工作,但我不知道为什么它不会成为内嵌,然后其他时候,它会结合到标题,我把它的权利。如果有更好的方法简单地做到这一点,请告诉我。我是用我目前所做的来自学的。
谢谢!
发布于 2015-11-08 02:43:17
由于您将a元素设置为display:block,所以它将重写li元素的内联属性。
我已经把你的代码放在一个小提琴里,以显示结果。
内插Nav条
发布于 2015-11-08 15:43:59
删除显示:块部分,所有内容都将移动到内联,因为您已经将所有li元素设置为内联。
若要将链接样式设置为按钮,请将以下内容添加到CSS中
ul a {
padding: 20px;
border-radius: 10px;
text-decoration: none;
}希望这能有所帮助!我也是自学成才,对事物非常陌生。
https://stackoverflow.com/questions/33589912
复制相似问题