css - react : background image overlaps navbar

标签 css reactjs react-router

您好,我正在开发一个 React 元素。 在 App.js 中,

return (
  <HashRouter>
    <Route path="/about" component={About} />
    <Navigation />
  </HashRouter>
);

我在 about.js 中添加了背景图片

.background {
  background-image: url('../source/loyoalfree.jpg');
  /* Full height */
  height: 100%; 

  /* Center and scale the image nicely */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

然后我仍然可以看到导航栏
但不能再点击导航栏。
我认为背景图像覆盖了导航栏。
我该如何解决这个问题?

最佳答案

您应该为图像添加 z-index。

.image { 
  position: relative;
  z-index: -1;
  /* your remaining css*/
}

关于css - react : background image overlaps navbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59437106/

相关文章:

react-router - React Router v4 - 如何检测后退按钮导航与 url 刷新?

reactjs - react 路由器要求未定义

javascript - React-JS : Uncaught TypeError: Cannot read property 'router' of undefined

css - 在展开时覆盖导航栏,而不是推送页面内容

html - 无法将页脚粘贴到底部。 CSS

javascript - 使用 slider 过渡复制粗体和非粗体

reactjs - 在全新的 create-react-app 安装(脚本访问 "/initrd.img"、 "/vmlinuz"等)的构建错误中检测到潜在安全威胁

html - 在我的案例中,如何在我的 <ul> <li> 选项卡上添加图像?

reactjs - React 与 React Fiber 有什么区别?

node.js - 从 react 记录到 aws cloudwatch