这里是一个完整的项目,我用最少的CSS创建了一个新项目,没有由我创建的CSS。结果是一样的。
下面是我的Home类的代码:
class Home extends React.Component{
state={};
render() {
return (
<div>
<div className="container">
<h1>Assignment Submission System</h1>
<p className="lead">To get latest notification, click
<tab>
<Link to={"/notifications"}>
here
</Link>
</tab>
.
</p>
<p>All enrolled class-rooms, assignment to-do list are shown.</p>
<h2 className="mt-4">Class-rooms:</h2>
<ClassRoomUnit displayName={"class 1"} classID={"4324ax"} hLink={"/class/asd"}/>
<ClassRoomUnit displayName={"class 2"} classID={"4324ax"} hLink={"/class/xzx"}/>
<ClassRoomUnit displayName={"class 3"} classID={"4324ax"} hLink={"/class/asd"}/>
<ClassRoomUnit displayName={"class 4"} classID={"4324ax"} hLink={"/class/asd"}/>
</div>
</div>
);
}
}
export default Home;但是问题是,当只有很少的ClassRoomUnit项时,它正确地呈现:

但是,当我添加更多的ClassRoomUnit时,第一部分和许多项就消失了,尽管滚动条仍然存在:

如何才能解决这个问题?
发布于 2019-09-19 13:07:21
发布于 2019-08-31 10:41:29
一定有一些CSS,某个类为您造成了这种情况。您能不能用我的例子stackblitz,从代码中进行更改,看看我们是否可以在这里复制这种情况--如果我们都能看到效果,那么帮助就容易多了。
我的index.js代码:
import React, { Component } from 'react';
import { render } from 'react-dom';
import Hello from './Hello';
import './style.css';
class ClassRoomUnit extends React.Component {
constructor(props) {
super(props);
this.state = { displayName: this.props.displayName, classID: this.props.classID, hLink: this.props.hLink }
}
render() {
return (<div class='row'>
<div class='col-4 themed-grid-col'> {this.state.displayName} </div>
<div class='col-4 themed-grid-col'> {this.state.classID} </div>
<div class='col-4 themed-grid-col'> <a href={this.state.hLink}>Go to class room</a> </div>
</div>)
}
}
class App extends Component {
constructor() {
super();
this.state = {
name: 'React'
};
}
render() {
return (
<div>
<div className="container">
<h1>Assignment Submission System</h1>
<p className="lead">To get latest notification, click here
.
</p>
<p>All enrolled class-rooms, assignment to-do list are shown.</p>
<h2 className="mt-4">Class-rooms:</h2>
<ClassRoomUnit displayName={"class 1"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 2"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 3"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 4"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 5"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 6"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 7"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 8"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 9"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 10"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 11"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 12"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 13"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 14"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 15"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 16"} classID={"4324ax"} hLink={"/class/asd"} />
</div>
</div>
);
}
}
render(<App />, document.getElementById('root'));工作斯塔克闪电战
https://stackoverflow.com/questions/57735934
复制相似问题