首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导航栏HTML未内联

导航栏HTML未内联
EN

Stack Overflow用户
提问于 2015-11-08 01:58:04
回答 2查看 386关注 0票数 0

关于这个话题,人们提出的所有问题都太复杂了,我已经看到了。我试着做一个基本的导航栏,我可以习惯HTML的工作方式。这是我的代码:

myFile.html:

代码语言:javascript
复制
<!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:

代码语言:javascript
复制
<!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>

我让它在一个点工作,但我不知道为什么它不会成为内嵌,然后其他时候,它会结合到标题,我把它的权利。如果有更好的方法简单地做到这一点,请告诉我。我是用我目前所做的来自学的。

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-11-08 02:43:17

由于您将a元素设置为display:block,所以它将重写li元素的内联属性。

我已经把你的代码放在一个小提琴里,以显示结果。

内插Nav条

票数 0
EN

Stack Overflow用户

发布于 2015-11-08 15:43:59

删除显示:块部分,所有内容都将移动到内联,因为您已经将所有li元素设置为内联。

若要将链接样式设置为按钮,请将以下内容添加到CSS中

代码语言:javascript
复制
ul a {
 padding: 20px;
 border-radius: 10px;
 text-decoration: none;
}

希望这能有所帮助!我也是自学成才,对事物非常陌生。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33589912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档