【问题标题】:Creating a header in HTML在 HTML 中创建标题
【发布时间】:2017-05-27 10:38:33
【问题描述】:

enter image description here

我想用这两条白线、徽标和导航栏为我的网站创建这个标题。

【问题讨论】:

  • 我们不是免费的代码编写服务,对不起。
  • 那你能告诉我怎么做白线吗? :)
  • border:solid white; border-width:2px 0;

标签: html css header navbar


【解决方案1】:

使用填充。
HTML:

<header>
   <div id="inner"></div>
</header>

css:

header{
    width:100%;
    background-color: blue;
    padding-top:10px;
    padding-bottom: 10px;
}
#inner{
    height: 80px;
    border-top: 2px solid white;
    border-bottom: 2px solid white;
    background-color: green;
}

或者做我喜欢的事,使用 flexbox。
(弹性盒) css:

header{
    width:100%;
    height: 200px;
    background-color: blue;
    display: flex;
    align-items: center;
}
#inner{
    width: 100%;
    height: 75%;
    border-top: 2px solid white;
    border-bottom: 2px solid white;
    background-color: green;
}

使用 Flexbox 既简单又直观。我推荐它。看看这个指南https://css-tricks.com/snippets/css/a-guide-to-flexbox/

【讨论】:

    【解决方案2】:

    body{background-color:brown;}
    ul{width:100%;padding:3px;text-align:right;border-top:1px solid white;border-bottom:1px solid white;}
    li{display:inline;margin-right:10px;cursor:pointer;height:100%;color:white;}
    li:hover{color:yellow;}
    <ul>
      <li>Home</li>
      <li>About</li>
    </ul>

    【讨论】:

      【解决方案3】:

      使用这个(替换文本、图片和链接到你想要的):

      <html>
      <head>
      <meta http-equiv="content-type"
      content="text/html; charset=ISO-8859-1">
      <title>Example</title>
      <style type="text/css">
      #nav {
      text-decoration: none;
      }
      </style>
      </head>
      <body
      style="color: rgb(0, 0, 0); background-color: rgb(255, 204, 153);"
      alink="#000099" link="#000099" vlink="#990099">
      <div style="width: 100%; height: 2px; background-color: white;"></div>
      <table style="text-align: left; width: 100%; height: 40px;"
      border="0" cellpadding="2" cellspacing="0">
      <tbody>
      <tr>
        <td style="width: 200px;"><img alt="logo"
      src="logo.png" style="width: 200px; height: 30px;"
      align="middle" hspace="10"></td>
        <td
      style="vertical-align: bottom; color: rgb(51, 51, 51); font-family: Times 
      New Roman;"><i>Site
      title</i></td>
        <td style="width: 40%;">
        <table
      style="width: 100%; text-align: left; margin-left: auto; margin-right: 0px;"
      border="0" cellpadding="2" cellspacing="0">
          <tbody>
            <tr>
              <td style="text-align: center;"><a
      href="link1.html" id="nav"
      style="color: rgb(153, 51, 0);">Link
      1</a></td>
              <td style="text-align: center;"><a
      href="link2.html" id="nav"
      style="color: rgb(51, 51, 51);">Link
      2</a></td>
              <td style="text-align: center;"><a
      href="link3.html" id="nav"
      style="color: rgb(51, 51, 51);">Link
      3</a></td>
              <td style="text-align: center;"><a
      href="link4.html" id="nav"
      style="color: rgb(51, 51, 51);">&nbsp;Link
      4</a></td>
            </tr>
          </tbody>
        </table>
        </td>
      </tr>
      </tbody>
      </table>
      <div style="width: 100%; height: 2px; background-color: white;"></div>
      </body>
      </html>
      

      白线:

      <div style="width: 100%; height: 2px; background-color: white;"></div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-12
        • 1970-01-01
        • 2021-08-11
        • 1970-01-01
        相关资源
        最近更新 更多