Css 反应引导卡标题内的换行导致卡向上移动 类条目扩展组件{ render(){ 返回( {this.props.albumTitle} {this.props.albumArtist} 进入相册 ); }

Css 反应引导卡标题内的换行导致卡向上移动 类条目扩展组件{ render(){ 返回( {this.props.albumTitle} {this.props.albumArtist} 进入相册 ); },css,reactjs,react-bootstrap,Css,Reactjs,React Bootstrap,} 我的卡中出现了换行问题。我试着在我的页面上列出几行卡片,每一行都有标题、文本和图片。我可以得到相同大小的卡片,但是如果标题超过一行,它会将卡片向上推,因此卡片没有正确排列。有什么建议吗 您应该截断文本。 你可以用它来做 class AlbumEntry extends Component { render() { return ( <Card style={{ margin: '5px', display: 'inline-block', width: '250

}


我的卡中出现了换行问题。我试着在我的页面上列出几行卡片,每一行都有标题、文本和图片。我可以得到相同大小的卡片,但是如果标题超过一行,它会将卡片向上推,因此卡片没有正确排列。有什么建议吗

您应该截断文本。 你可以用它来做

class AlbumEntry extends Component {
render() {
    return (
        <Card style={{ margin: '5px', display: 'inline-block', width: '250px', height: '500px' }}>
            <Card.Img variant="top" src={this.props.imgSrc}/>
            <Card.Body style={{display: 'inline-block'}}>
                <Card.Title> {this.props.albumTitle} </Card.Title>
                <Card.Text> {this.props.albumArtist} </Card.Text>
                <Button variant="primary">Go to Album </Button>
            </Card.Body>
        </Card>
    );
}
或者你可以使用增加卡片的高度,这占据了两行标题的高度

.truncate {
  width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
类条目扩展组件{
render(){
返回(
{this.props.albumTitle}
{this.props.albumArtist}
进入相册
);
}
}

您需要强制执行固定高度,否则您的卡将不符合预期顺序。

您应该截断文本。 你可以用它来做

class AlbumEntry extends Component {
render() {
    return (
        <Card style={{ margin: '5px', display: 'inline-block', width: '250px', height: '500px' }}>
            <Card.Img variant="top" src={this.props.imgSrc}/>
            <Card.Body style={{display: 'inline-block'}}>
                <Card.Title> {this.props.albumTitle} </Card.Title>
                <Card.Text> {this.props.albumArtist} </Card.Text>
                <Button variant="primary">Go to Album </Button>
            </Card.Body>
        </Card>
    );
}
或者你可以使用增加卡片的高度,这占据了两行标题的高度

.truncate {
  width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
类条目扩展组件{
render(){
返回(
{this.props.albumTitle}
{this.props.albumArtist}
进入相册
);
}
}
您需要强制执行固定高度,否则您的卡将不符合预期顺序