简体   繁体   English

将徽标与菜单对齐

[英]Aligning a logo with a menu

I'm trying to align a simple nav bar with the logo on the left and the menu + searchbar on the right.我正在尝试将一个简单的导航栏与左侧的徽标和右侧的菜单 + 搜索栏对齐。 I just can't figure out how to get them horizontally aligned.我只是不知道如何让它们水平对齐。 I'm working mobile first with media queries.我首先使用移动设备进行媒体查询。 I feel like this should have a really simple fix but I just can't see it.我觉得这应该有一个非常简单的修复,但我就是看不到。

here's my HTML and CSS这是我的 HTML 和 CSS

 @media screen and (max-width: 1499px) and (min-width: 1153px) {.navbar-toggle, .main-nav.social { display: none; }.main-nav { display: inline; text-align: center; padding: 10px 0px 10px 0px; margin-top: 20px; }.main-nav li { display: inline; border: none; }.main-nav a { padding: 10px; }.navbardesk { display: flex; }.logo { order: 0; }.mainnav { order: 1; }.searchicon { order: 3; } header { max-width: 1153px; margin-bottom: 10px; }
 <header> <span class="navbar-toggle" id="js-navbar-toggle"> <i class="fas fa-bars"></i> </span> <div class="navbardesk"> <h1 class="logo">Buurtsuper Leo van der Drift</h1> <ul class="main-nav" id="js-menu"> <li><a href="" class="nav-links">Home</a></li> <li><a href="" class="nav-links">Over ons</a></li> <li><a href="" class="nav-links">Kantoren en bedrijven</a></li> <li><a href="" class="nav-links">Bestellen</a></li> <li class="nav-links social"> <i class="fab fa-facebook-square"></i> <i class="fab fa-instagram"></i></li> </ul> <i class="fas fa-search searchicon"></i> </div> <p class="welkomtekst"> Welkom.<br> Bij buurtsuper Leo vd Drift bent u aan het juiste adres als het gaat om verse producten. </p> </header>

oh and here's the codepen: https://codepen.io/radartrinkets/project/editor/XgWOvG哦,这是代码笔: https ://codepen.io/radartrinkets/project/editor/XgWOvG

You can use "flex" to align items.您可以使用“flex”来对齐项目。 Example:例子:

.v-align{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
}

And you use "v-align" class on parent div of menu and logo, it will center your content on X and Y axis.并且您在菜单和徽标的父 div 上使用“v-align”类,它将使您的内容在 X 轴和 Y 轴上居中。 if you want to lose X axis, you can delete "justify-content" part如果你想失去 X 轴,你可以删除 "justify-content" 部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM