简体   繁体   English

在移动设备上修复WordPress导航栏对齐(响应)

[英]Fixing WordPress navbar alignment on mobile devices (responsive)

Website: www.tarbooshla.com 网站:www.tarbooshla.com

When viewed on a mobile device, the search icon is not aligned with the rest of the navbar (the logo and the menu icon). 在移动设备上查看时,搜索图标未与导航栏的其余部分(徽标和菜单图标)对齐。 How can I fix this? 我怎样才能解决这个问题?

I have tried updating all the themes and plugins to no avail. 我尝试更新所有主题和插件都无济于事。

It seems to be displaying exactly as intended with the current rule set. 它似乎完全按照当前规则集显示。 I'm assuming you want it to populate on the right? 我假设您希望它填充在右边? I was able to move it substantially with the padding property, however I don't think that's the best scenario for you. 我可以使用padding属性对其进行实质性的移动,但是我认为这不是适合您的最佳方案。 The search icon is currently not text at all, but a pseudo element displayed in an ::before scenario, if you want it to show up after when it reaches a certain size, I recommend having a media query that sets it to display:none; 搜索图标当前根本不是文本,而是显示在::before场景中的伪元素,如果您希望它在达到一定大小后显示,我建议使用媒体查询将其设置为display:none; and an ::after pseudo element that displays when it gets to your smart phone @media and screen (max-width) size. ::after伪元素,当它到达您的智能手机@media and screen (max-width)大小时显示。

发生这种情况是因为移动设备的空间有限。因此,您可以做的是进入header.php并将搜索栏与首页,关于我们的内容一起放在主导航栏中,因此一旦用户按一下,搜索就会出现菜单按钮。或者在CSS的帮助下,将菜单向左对齐,以便搜索按钮可以位于右侧。

This code may help you. 此代码可以为您提供帮助。 Make sure to add this CSS code at a place so that it loads after all other css is loaded ( therefore taking maximum priority ) 确保在某个地方添加此CSS代码,以便在加载所有其他CSS之后加载它(因此具有最高优先级)

@media only screen and (max-width: 767px) {
    #Top_bar .logo {
        text-align: left;
    }

    #Top_bar .top_bar_left {
        float: left;
        width: 80% !important;
        margin-top: 10px;
        background: none !important;
    }

    .header-classic #Top_bar .top_bar_right {
        top: 15px;
        float: right;
    }

}

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

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