Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

javascript - When the navigation bar is position: fixed how can i solve problems that overlap with other components?

I want to fix the navigation bar always on the top so i gave position: fixed by css, but it overlaps with the components below, causing a problem where I cannot see the contents. Tell me how to solve it.

For example // I gave opacity to nav bar

example image

here is my code

Navigation css

.Navigation {
                display: flex;
                position: fixed;
                z-index: 9999999999;
                top: 0;
                left: 0;
                width: 100vw;
                box-sizing: border-box;
                padding: 20px 50px;
                justify-content: space-between;
                background-color: #eee;
                opacity: 0.33;
                flex: 1
            }

App.js

                      <div className="App">
                      <Navigation />
                      <Home/>
                      <Blog/>
                      <Projects/>
                      <Contact/>
                      <Router/>
                      <GlobalStyles/>
                  </div>
question from:https://stackoverflow.com/questions/65885793/when-the-navigation-bar-is-position-fixed-how-can-i-solve-problems-that-overlap

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Styling like this

.navigation {
   .....
   height: 65px, % , em, rem;
}

.content-container {
   margin-top: 65px, % , em, rem;
   .....
}

Wrap your components like this

<div className="app">
     <Navigation />
     <div className="content-container">
         <Home/>
         .......
        <GlobalStyles/>
     </div>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...