代码之家  ›  专栏  ›  技术社区  ›  Karim Sawma

react web app中缺少滚动条

  •  0
  • Karim Sawma  · 技术社区  · 7 年前

    我用react创建了一个界面,但是当我在屏幕上添加更多的项目时,屏幕就会满了,向下滚动条就不会出现,我也看不到页面末尾的元素。谢谢你抽出时间,我真的很感激。

    这个css写在一个文件夹中,它是我所有页面的css的一部分,我不知道这是否会造成这个问题

    css代码:

    .App-header {
      position: fixed;
      display: block;
      width: 100%;
      background-color: #222;
      color: #FFFF;
      height:90px;
      position: fixed;
    }
    .App-header ul li{
      float:left;
      padding-top:25px;
      padding-left: 10px;
      padding-bottom: auto;
    }
    .App-header ul li h1{
    display:inline;
    padding-left: 8px;
    padding-right: 8px;
    }
    .App-header ul li{
    display:inline;
    }
    .App-header ul li a{
    text-decoration:none;
    font-size:15px;
    font-weight:bold;
    color:white;
    }
    .App-header ul li a:hover{
    text-decoration:underline;
    text-decoration-color: red;
    }
    
    .Body{
      position:absolute;
      margin-top: 90px;
      width:100%;
    }
    .Body h1 {
      color: black;
    }
    .Body p{
      color:black;
    }
    .Newfeeds {
      float:right;
      border: solid red;
      margin-right:10px;
      width:200px;
    }
    .Newfeeds h1{
      font-size: 20px;
      text-decoration:underline;
    }
    .weather{
      border: solid green;
      float:left;
      height:400px;
      width:400px;
      margin-left:15px;
    }
    

    这是react代码,用于使我的界面有另一个名为index的页面,其中唯一的代码是在页面之间创建路径,它也有标题。

    主页代码:

    import React, {Component} from 'react';
    import '../Css/App.css';
    class HomePage extends Component {
      render(){
        return(
          <div className="Body">
            <div className="Newfeeds">
              <h1>Your daily information</h1>
    <p>A Kangaroo cannot walk backwards.
    
    The San Francisco cable cars are the only mobile National Monuments.
    
    The only 15 letter word that can be spelled without repeating a letter is uncopyrightable.
    
    Non - dairy creamer is flammable
    
    A duck's quack doesn't echo and no one knows why.
    Although, the show Brianiac has proved that it does in fact does echo.
    
    In the Wizard of Oz Dorothy's last name is
    Gail. It is shown on the mail box.</p>
    </div>
          <div className="weather">
    
          </div>
        </div>
        );
      }
    }
    export default HomePage;
    

    感谢您抽出时间,我希望我能很好地描述我的问题:)

    3 回复  |  直到 7 年前
        1
  •  2
  •   obsidian    7 年前

    我没有确切的答案,但我要做的是,我会去删除一个又一个css属性,甚至可能是特定类上的整个css属性块,直到我找到导致问题的行

    您是否在github上有此代码,以便我下载并查看是否可以为您解决此问题?

        2
  •  0
  •   yanhua    7 年前

    尝试添加 overflow-y: auto .Body{} 在css中

        3
  •  0
  •   blazej RustyNova    3 年前

    造成这个问题的原因有很多。你必须做点什么:

    1. 当滚动条消失时,去检查并寻找滚动条必须存在的主容器。尝试将CSS属性修改为“100%”,这可能会像对我一样对你有用。
    2. 通过执行以下步骤,可以使滚动条始终可见:
    html {
    
        overflow: -moz-scrollbars-vertical;
        overflow-y: scroll;
    }
    
    1. 如果以上两个都不起作用,你可以试试 overflow-y: auto;