【问题标题】:React Footer overlapping componentReact Footer 重叠组件
【发布时间】:2022-01-09 22:21:19
【问题描述】:

我一直在尝试创建一个粘在底部而不重叠任何组件的页脚,但我遇到了一些困难。

我在索引中使用了以下代码:

.footer{
  margin-top: 1rem;
  padding: 1rem;
  background-color: #3D938B;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
}

我还添加了页脚,就像页面中的任何其他组件一样...

<Router>
  <NavBar></NavBar>
  <div className={classes.topMargin}>
    <Route exact path="/contact-us" element={<ContactUs/>}/>
  </div>
  <Footer></Footer>
</Router>

我的联系我们页面具有以下 CSS:

@media only screen and (max-width: 700px) {
    .form-container {
        text-align: center;
    }
    .button-submit {
        background-color: white;
        width:7rem;
        border-radius: 10px;
        border: 2px solid #3D938B;
        color: #3D938B;
        padding: 5px;
        margin-bottom:20px;

    }
}

提前致谢!!

【问题讨论】:

  • 您需要minimal reproducible example。因为它没有足够的信息来帮助你。
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: css reactjs frontend footer styling


【解决方案1】:

您可以使用它使页脚固定在底部而不与其他元素重叠。

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#footer {
  background-color: #3D938B;
  flex: 0 0 50px;
  margin-top: auto;
}

【讨论】:

  • 您好,感谢您的回复。我的脚下没有身体。上面的css会应用到页脚组件吗?
猜你喜欢
  • 2015-10-07
  • 1970-01-01
  • 2019-12-17
  • 2017-03-24
  • 2017-05-21
  • 1970-01-01
  • 1970-01-01
  • 2020-06-21
  • 1970-01-01
相关资源
最近更新 更多