html - 如何完美对齐 Logo 、导航栏和 Logo

标签 html css sass styles haml

经过多次研究后,我没有弄清楚如何将我的 Web 应用程序的 Logo 与导航项对齐。我创建了 Logo 图像,但无法以正确的方式对齐它! 希望你们中的一些人能帮助我。

这是Haml代码

  %header
     .header_inner
     = link_to image_tag('loo.png'), root_path, id: "logo"
     %nav
        - if user_signed_in?
           = link_to "New Note", new_note_path
           = link_to "Sign Out", destroy_user_session_path, method: :delete 
       - else
           = link_to "Log In", new_user_session_path

这里是 Sass 代码

header {
background: $dark_gray;
position: fixed;
top: 0;
width: 100%;
padding: 1.75rem 0;
border-bottom: 7px solid $green;
.header_inner {
    width: 90%;
    margin: 0 auto;
    #logo {
        float: left;
        padding: 1px 0;
    }
    nav {
        display: inline-block;
        width: 10px;
        float: left;
        a {
            text-decoration: none;
            color: white;
            font-size: 1.1rem;
            line-height: 1.5;
            margin-left: 1rem;
            &:hover {
                color: $green;
            }
        }
    }
}

以及导航栏样式的结果 Navbar Styling Result - Application Image

最佳答案

因为你们已经提供了一些 css,例如:float:left, margin-left:1rem 等等。

做点什么

float:none
margin:0 auto;
display:inline-block;
width:100%

希望这对你有帮助...

关于html - 如何完美对齐 Logo 、导航栏和 Logo ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42045125/

相关文章:

html - 高度为100%的div超出页面可见区域

css - 使用 webpack 引导

HTML 使用包含自定义字体的 SVG 图像

html 文本标签的高度和宽度没有改变

javascript - Bash Script在网页上的格式化输出

php - 跟踪 CDN 文件上的请求

css - CSS 标签限定(例如 h1.some-class)有什么问题?

ruby-on-rails - Rails Sass 在快速开发机器中编译太慢

Javascript计算从多个选择中选择了多少个

javascript - 查找与 HTML 文档中的模式匹配的所有类?