这个多余的水平空间是从哪里来的?

奥利·特鲁特

我正在为一个使用Reactstrap和我的自定义CSS的大学项目构建React.js网站应用程序。我刚刚注意到我可以进行水平滚动,但是我无法弄清楚它的来源。

您可以看到图像上的多余空间,这似乎与导航栏有关,但我不知道为什么,并且已经使用了很多CSS。我一定会完全想念什么吗?

水平空间示例屏幕截图

Navbar.js组件的代码:

import Navbar from 'react-bootstrap/Navbar';
import Nav from 'react-bootstrap/Nav';
import Button from 'react-bootstrap/Button';
import {
  Link
} from 'react-router-dom';

class NavBar extends React.Component {
  render() {
    return (
      <Navbar expand="md" className="custom-nav-bg fixed-top">
        <Navbar.Brand expand="lg" href="#home">
        <Link to="/home"><img className="custom-nav-logo"
            src="logohero.png"
            alt="StatHero Logo"
            width="105px"
            height="50px"
          /></Link>
        </Navbar.Brand>
        <Nav className="collapse navbar-collapse mr-auto justify-content-end">

          <Nav.Link className="custom-nav-text" href="#about">
          <Link to="/about">ABOUT</Link>
          </Nav.Link>

          <Nav.Link className="custom-nav-text" href="#stats">
          <Link to="/stats">STATS</Link>
          </Nav.Link>

          <Nav.Link className="custom-nav-text" href="#faqs">
          <Link to="/faq">FAQS</Link>
          </Nav.Link>

          <Nav.Link className="custom-nav-text" href="#contact">
          <Link to="/contact">CONTACT</Link>
          </Nav.Link>

          <Nav.Link className="custom-nav-text" href="#signup">
            <Button className="custom-nav-button">SIGN UP</Button>
          </Nav.Link>

          <Nav.Link className="custom-nav-text" href="#login">
          LOGIN
          </Nav.Link>

        </Nav>

    </Navbar>
    )
  }
}
export default NavBar;

我的custom.css的代码:

  background-color: #132A42;
  border-radius: 0px;
  padding-left: 60px;
  padding-right: 50px;
}

.custom-nav-logo {
  height: 100%;
}

a:focus, a:hover, a:active {
  color: white ! important;
  font-family: 'Assistant', sans-serif ! important;
  font-weight: 650 ! important;
  text-decoration: none;
}

a.custom-nav-text:hover {
  color: white ! important;
  font-family: 'Assistant', sans-serif ! important;
  font-weight: 700 ! important;
}

.custom-nav-text {
  color: white ! important;
  font-family: 'Assistant', sans-serif;
  font-weight: 600;
  padding-left:20px ! important;
  padding-right:20px ! important;
  padding-top:10px ! important;
  padding-bottom:10px ! important;
  font-size: 20px;
}

.custom-usp-1 {
  background-color: #F6F7F8;
}

.custom-usp-2 {
  background-color: white;
}

.custom-nav-button {
  border-radius: 20px;
  border-color: #00DF8D;
  background-color: #00DF8D;
  font-size: 20px;
  font-weight: 600;
  padding-left: 15px;
  }

  .custom-jumbo-button {
    border-radius: 35px;
    border-color: #00DF8D;
    background-color: #00DF8D;
    font-size: 40px;
    font-weight: 600;
    padding-left: 50px;
    padding-right: 50px;
    text-align: center;
    margin-top: 10px;
    }

.CTA {
  background-color: #C42B32;
}

.custom-jumbo {
  padding-bottom: 150px ! important;
  padding-top: 210px ! important;
  background-color: #132A42;
  margin-bottom: 0px;
  padding-left: 75px;
}

h1 {
  color: white ! important;
  font-family: 'Assistant', sans-serif;
  font-size: 50px ! important;
  font-weight: 700;
}

h2 {
  color: white ! important;
  font-family: 'Assistant', sans-serif;
  font-size: 25px;
  text-align: center;
  padding-top: 10px;
  padding-bottom: 8px;
  font-weight: 600;
  letter-spacing: 3px;
}

p {
  color: white ! important;
  font-family: 'Assistant', sans-serif;
  font-size: 30px ! important;
}

h3 {
  color: black ! important;
  font-family: 'Assistant', sans-serif;
  font-size: 30px;
  text-align: center;
  padding-top: 40px;
  padding-bottom: 5px;
  font-weight: 600;
}

h4 {
  color: #C42B32 ! important;
  font-family: 'Assistant', sans-serif;
  font-size: 40px;
  text-align: center;
  padding-bottom: 15px;
  font-weight: 600;
}

.USPp {
  color: black ! important;
  font-family: 'Assistant', sans-serif;
  font-size: 20px ! important;
  text-align: center;
  padding-right: 60px ! important;
  padding-left: 60px ! important;
  font-weight: 500;
  padding-bottom: 50px;
}

.customCard {
  font-family: 'Assistant', sans-serif;
  font-weight: 550;
  color: #C42B32 ! important;
  text-align: center;
  font-size: 20px ! important;
}

.cardContent {
  padding-left: 30px;
  padding-right: 30px;
  padding-top: 30px;
  padding-bottom: 20px;
  border: 0px solid rgba(0,0,0,.125) ! important;
}

.JumboImg {
  background-color: #132A42;
  height: 500px;
}

.customFooter {
  background-color: #132A42;
  height: 200px;
}
 a {
   color: white;
 }

如果需要,我可以在页面上提供其他组件的代码。

奥利·特鲁特

解决了

这是其他组件之一的问题。

我使用开发工具来手动遍历和删除元素,以找出哪个元素引起了水平滚动。然后,我通过添加该组件来编辑CSS

最大宽度:100%;

这是关于如何执行此操作的非常有用的教程:https : //css-tricks.com/findingfixing-unintended-body-overflow/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章