I have a component with fixed width
and height
. I need to show a list of items in it. I used overflow: scroll;
but it doesn't show the whole list! For instance, if I have 10 items, it doesn't show items 1,2 and maybe half of 3!
I tried all things i found online, such as adding padding
, height
, or change it to overflow: auto;
but neither worked!
SCSS:
.cart-dropdown {
width: 300px;
height: 400px;
background-color: aqua;
position: absolute;
top: 60px;
right: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 2px solid black;
z-index: 10;
.cart-items {
padding:10px;
overflow: auto;
width: 100%;
height: 320px;
margin: 5px;
background-color: cornflowerblue;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.button {
margin: auto;
}
}
Component:
const cartDropdown = ({cartItems}) => {
const renderCartItem = cartItems => {
return cartItems.map(item => <CartItem key={item.imageUrl} item={item} />);
};
return (
<div className="cart-dropdown">
<div className="cart-items">{renderCartItem(cartItems)}</div>
<div className="button">
<Button>GO TO CHECKOUT</Button>
</div>
</div>
);
};
const mapStateToProps = ({ cartStatus: { cartItems } }) => ({
cartItems
});
export default connect(mapStateToProps)(cartDropdown);