首頁 > web前端 > css教學 > 主體

為什麼我的導覽列和漢堡選單會在較小的螢幕上消失?

DDD
發布: 2024-11-14 21:38:02
原創
536 人瀏覽過

Why Does My Navbar and Hamburger Menu Disappear on Smaller Screens?

Fixing Vanishing Navbar and Hamburger Menu on Smaller Screens

Problem:

A navbar with a logo image in the center functions flawlessly on large screens. However, when the screen is reduced, everything, including the logo image and hamburger menu, vanishes. How can this issue be resolved?

Solution:

To maintain visibility on smaller screens, ensure that the navbar has either a background color or the appropriate CSS classes added:

  • For Bootstrap 5: Use navbar-light or navbar-dark along with navbar-light bg-light or navbar-dark bg-dark for background color.
<nav>
登入後複製
登入後複製
  • For Bootstrap 4.0.0 and older: Use either navbar-light bg-light or navbar-dark bg-dark, or add a custom background color via CSS.
<nav>
登入後複製
登入後複製
#navbar-primary .navbar-nav {
  background: #ededed;
}
登入後複製

Alternatively, you can darken the hamburger toggler to improve its visibility.

.navbar-toggle .icon-bar {
  background-color: rgb(136, 136, 136);
}
登入後複製

Updated Information:

For Bootstrap 5, the navbar-light or navbar-dark classes are essential for displaying the hamburger menu.

以上是為什麼我的導覽列和漢堡選單會在較小的螢幕上消失?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板