滚动条在列表下消失
Scrollbar disappears under list
正如标题所说,我试图用 <Scrollbars>
包裹 <ListGroup>
但是当我将鼠标悬停在它上面时,滚动条在其中一个项目下消失了。我没有应用任何 css
。这是一个 React
应用程序。有什么解决办法吗?
这是顶部的示例代码div
import React from 'react';
import { Card, ListGroup, ListGroupItem, Badge, ListGroupItemText } from 'reactstrap';
import { Scrollbars } from 'react-custom-scrollbars';
<div className="shadow-sm">
<Card>
<Scrollbars style={{ width: 350, height: 250 }} >
<ListGroup>
<ListGroupItem className="justify-content-between">Cras justo odio <Badge pill>14</Badge>
<ListGroupItemText>
Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
</ListGroupItemText>
</ListGroupItem>
<ListGroupItem className="justify-content-between">Dapibus ac facilisis in <Badge pill>2</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Dapibus ac facilisis in <Badge pill>2</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
</ListGroup>
</Scrollbars>
</Card>
</div>
这里有一张图片可以进一步说明
这是我为这两个组件找到的 css
// scroll-bar
element.style {
position: relative;
display: block;
width: 100%;
cursor: pointer;
border-radius: inherit;
background-color: rgba(0, 0, 0, 0.2);
height: 161px;
transform: translateY(26.5865px);
// list-item
.list-group-item {
position: relative;
display: block;
padding: 0.75rem 1.25rem;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.125);
}
I can add a margin but I don't like how it looks. I would rather have the scrollbar on top of the list - since I can also choose to hide it when not scrolling. Thanks
我已按照此处所述添加自定义样式来修复它 https://github.com/malte-wessel/react-custom-scrollbars/blob/master/docs/customization.md
// in css
.thumb-vertical {
background-color: rgba(0, 0, 0, 0.6);
border-radius: 3px;
z-index: 2;
cursor: pointer;
}
// in component
<Scrollbars
renderThumbVertical={props => <div {...props} className="thumb-vertical"/>}
> ...
</Scrollbars>
正如标题所说,我试图用 <Scrollbars>
包裹 <ListGroup>
但是当我将鼠标悬停在它上面时,滚动条在其中一个项目下消失了。我没有应用任何 css
。这是一个 React
应用程序。有什么解决办法吗?
这是顶部的示例代码div
import React from 'react';
import { Card, ListGroup, ListGroupItem, Badge, ListGroupItemText } from 'reactstrap';
import { Scrollbars } from 'react-custom-scrollbars';
<div className="shadow-sm">
<Card>
<Scrollbars style={{ width: 350, height: 250 }} >
<ListGroup>
<ListGroupItem className="justify-content-between">Cras justo odio <Badge pill>14</Badge>
<ListGroupItemText>
Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
</ListGroupItemText>
</ListGroupItem>
<ListGroupItem className="justify-content-between">Dapibus ac facilisis in <Badge pill>2</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Dapibus ac facilisis in <Badge pill>2</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
<ListGroupItem className="justify-content-between">Morbi leo risus <Badge pill>1</Badge></ListGroupItem>
</ListGroup>
</Scrollbars>
</Card>
</div>
这里有一张图片可以进一步说明
这是我为这两个组件找到的 css
// scroll-bar
element.style {
position: relative;
display: block;
width: 100%;
cursor: pointer;
border-radius: inherit;
background-color: rgba(0, 0, 0, 0.2);
height: 161px;
transform: translateY(26.5865px);
// list-item
.list-group-item {
position: relative;
display: block;
padding: 0.75rem 1.25rem;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid rgba(0, 0, 0, 0.125);
}
I can add a margin but I don't like how it looks. I would rather have the scrollbar on top of the list - since I can also choose to hide it when not scrolling. Thanks
我已按照此处所述添加自定义样式来修复它 https://github.com/malte-wessel/react-custom-scrollbars/blob/master/docs/customization.md
// in css
.thumb-vertical {
background-color: rgba(0, 0, 0, 0.6);
border-radius: 3px;
z-index: 2;
cursor: pointer;
}
// in component
<Scrollbars
renderThumbVertical={props => <div {...props} className="thumb-vertical"/>}
> ...
</Scrollbars>