简体   繁体   English

当我单击导航栏按钮时,我的搜索栏宽度正在改变

[英]My search bar width is changing when i click navbar button

In this app when I toggle between home and about page button in the navbar,My search bar's width is changing why???在这个应用程序中,当我在导航栏中的主页和关于页面按钮之间切换时,我的搜索栏的宽度为什么会改变??? (For desktop only). (仅适用于台式机)。

My Code: https://github.com/StrikerOne65/snewz我的代码: https : //github.com/StrikerOne65/snewz

.main-nav {
    display: flex;
    margin-right: 30px;
    justify-content: flex-end;
    width: 75%; -- ADD THIS TO DETERMINE OVER ALL WIDTH OF THE NAV
}

.main-nav li:first-of-type{
    /* padding-right: 25%; */ -- REMOVE THIS
    width: 50%; -- ADJUST THIS FOR YOUR WIDTH OF SEARCH BAR: WHATEVER PERCENT OF .MAIN-NAV

margin-right: 5%;右边距:5%; } }

.search {
    display: flex;
    /* width: 150%; */ -- REMOVE THE 150% WIDTH
}

So to explain, you are mixing a lot of fixed widths within flex and trying to overstyle to compensate所以解释一下,你在 flex 中混合了很多固定宽度并试图过度设计来补偿

The .main-nav you have set to flex-end to set it to the right, you just needed to make it larger to contain all of the content of the <li> within it and not force an child element to try to be 150% width of its parent - its trying to break out of the layout.您已将 .main-nav 设置为 flex-end 以将其设置为右侧,您只需要将其放大以包含其中的<li>所有内容,而不是强制子元素尝试为 150 % 其父级的宽度 - 它试图打破布局。 I think its this that is your issue我认为这是你的问题

暂无
暂无

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

相关问题 如何使用搜索栏过滤我的bootstrap 4导航栏链接? - How can I filter my bootstrap 4 navbar links with a search bar? 在移动设备上,我希望在单击 ID 时关闭导航栏 - On mobile I want my navbar to close when I click an ID 单击其中一个部分时如何关闭导航栏? - How to close my navbar when I click on one of the sections? 为什么单击菜单图标时我的正常导航栏消失了 - Why is my normal navbar disappearing when I click on the menu icon Bootstrap 5:我需要做什么才能在导航栏中有一个搜索图标,当我单击它时,它会在导航栏下方显示一个搜索框? - Bootstrap 5: What I need to do to have a search icon in navbar that when I click it, it will show a search box under the navbar? 如何在我单击搜索按钮时才显示表格输出 - how do i make my table output appear only when i click on the search button 导航栏在我点击时闪烁 - Navbar flashing when i click it 我创建了 css 导航栏,我选择的导航按钮没有改变它的颜色,而是另一个按钮正在改变它的颜色 - I have created css navbar, my selected nav button is not changing its colour,instead another button is changing its colour 当我点击按钮时,它什么也没做 - My button does nothing when i click on it 我有一个粘性导航栏(搜索栏),但是当您向下滚动时它仍然与页面内容重叠 - I have a sticky navbar (search bar) but it still overlaps with the contents of the page when you scroll down
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM