html - 垂直对齐导航栏中包含 Logo 的文本

标签 html css

我的导航栏中的 Logo 左对齐,中的链接右对齐,但链接在导航栏中垂直居中。无论我做什么,我都无法让它居中。在此先感谢您的帮助。这是我的代码:

HTML

  <div class="navbar-fixed">
    <nav>
      <div class="nav-wrapper">
        <ul>

        <a href = "index.html" class = "nav-logo"><img src="images/mo's_logo.png" title = "Go to Mo's Gyros Home" alt = "Mo's Gyros logo"></a>
          <li><a href="#">Home</a></li>
          <li><a href="#">About Us</a></li>
          <li><a href = "#">Specials</a></li>
          <li><a href = "#">Events</a></li>
        <li><a href = "#">Contact Us</a></li>
        </ul>
      </div> <!-- end of nav-wrapper -->
    </nav>
  </div> <!-- end of navbar-fixed -->

CSS

#nav-wrapper {
}

nav { 
        width: 100%;
        height: 38px;
        padding: 5px;
        position: fixed;
        background-color: #5c5453;
}

.navbar-fixed {
        padding: 0;
}

.nav-logo {
        float: left;
        padding-left: 160px;
}

nav li { 
        display: inline;
        list-style-type: none;
        padding-right: 50px;
}

a { 
        color: #8CBAD9;
        text-decoration: none; 
}

a:hover { 
        color: white;
        text-decoration: underline;
}

ul {
    text-align: right;
}

最佳答案

试试这个 https://jsfiddle.net/vb8yspjs/1/

只需在您的 CSS 中更改它

ul {
  text-align: right;
  margin: 0;
  line-height: 38px;
}

关于html - 垂直对齐导航栏中包含 Logo 的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33324546/

相关文章:

javascript - 如何在 Angularjs 中模拟 HTML 表单请求?

html - 在曲线中显示 html 列表

css - 如何在不将内容推出屏幕的情况下添加边距?

html - Modal 在 IE10 中不工作,但在其他浏览器中工作正常

css ->=Rails 3.1 如何在 Assets 管道中包含 IE 特定的 YAML-CSS 文件

javascript - 单击一个元素然后执行其他相同的单击事件?

javascript - 将页面转换为矩阵样式

CSS nth-child 1-6、7-12 等

javascript - -ms-high-contrast-adjust 在 IE9 中等效

javascript - 运行按钮的功能