How to adjust the frame size?

Good evening,

In my shopping cart I notice that when my description is too long it goes beyond the frame.

How do I resolve this in my css?

I think I need to correct this in the css class: eachCart.

Do you have an idea ?

My css

/* Shopping Cart List */
.cartContainer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 0;
    max-width: 500px;
    z-index: 1000;
    background-color: #F8F8F8;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    overflow-y: scroll;
    scrollbar-width: thin;
    transition: all .5s ease-in-out;
}

.showCartContainer {
    width: 80%;
    padding: 1em;
    box-shadow: 0 0 15px 15px rgba(0, 0, 0, .4);
}

.closeCart {
    text-align: right;
    margin-bottom: 1em;
    cursor: pointer;
    font-size: 1.1rem;
    width: 50px;
    float: right;
    border-bottom: 2px solid #BA704F;
}

#cartTitle {
    font-size: 1.5rem;
    color: #BA704F;
    font-weight: 900;
}

.eachCart {
    width: 97%;
    display: grid;
    grid-template-columns: 1fr 5fr;
    align-items: center;
    gap: 5px;
    background-color: white;
    margin: .5em;
    border-radius: 10px;
    box-shadow: 0 0 3px 1px rgba(0, 0, 0, .1);
    height: 110px;
    padding: .5em;
}

.cartImg {
    width: 100%;
}

.cartItemName {
    font-size: 1rem;
}

.cartItemPrice {
    font-weight: 500;
    font-weight: bold;
}

.cartDesc {
    margin-left: 2em;
    color: #DFA878;
}

.remove {
    border: none;
    background-color: #BA704F;
    padding: .5em;
    font-size: .9rem;
    color: white;
    font-weight: bold;
    border-radius: 5px;
    margin-top: .3em;
    cursor: pointer;
    border: 2px solid #BA704F;
    transition: all .2s ease-in-out;
}

.remove:hover {
    color: red;
    border: 2px solid #DFA878;
    background-color: transparent;
}

#totalPriceContainer {
    background-color: #BA704F;
    width: 100%;
    text-align: center;
    padding: 1em;
    color: white;
    border-radius: 10px;
}

#totalPrice {
    font-weight: 900;
}

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f1bc0d;
    border-radius: 0.5rem;
    padding: 0.5rem;
    text-decoration: none;
    transition: 0.2s ease-out;
}

.back-to-top span {
    color: #fff;
    font-size: 3rem;
    transition: 0.2s ease-out;
}

.back-to-top:hover {
    background-color: #efc127;
}

.back-to-top:hover span {
    transform: translateY(-4px);
}

html code

return eachCartItemContainer.innerHTML +=
                    `<div class="eachCart">` +
                    ` <img src="./img/${productImg}" class="cartImg" alt="">` +
                    `<div class="cartDesc">` +
                    `<h1 class="cartItemName">${productName}</h1>` +
                    `<p class="cartItemPrice">${productPrice}€</p>` +
                    `<button class="remove" id="remove${id}">Remove</button>` +
                    `</div>` +
                    `</div>`

You have a fixed height if 110px. Change it to min-height instead.

that’s to say ? I tried to decrease to 70px and 80 and it doesn’t work, it shifts even more.

Or maybe I didn’t quite understand when you said minimal?

I was perhaps thinking of replacing the remove button with a trash can icon, but how do I do that?

`<button class="remove" id="remove${id}">Remove</button>`
.remove {
    border: none;
    background-color: #BA704F;
    padding: .5em;
    font-size: .9rem;
    color: white;
    font-weight: bold;
    border-radius: 5px;
    margin-top: .3em;
    cursor: pointer;
    border: 2px solid #BA704F;
    transition: all .2s ease-in-out;
}

.remove:hover {
    color: red;
    border: 2px solid #DFA878;
    background-color: transparent;
}

I didn’t say anything about decreasing the height?

Change the height property to min-height.

e.g.


.eachCart {
    width: 97%;
    display: grid;
    grid-template-columns: 1fr 5fr;
    align-items: center;
    gap: 5px;
    background-color: white;
    margin: .5em;
    border-radius: 10px;
    box-shadow: 0 0 3px 1px rgba(0, 0, 0, .1);
    min-height: 110px;
    padding: .5em;
}
1 Like

Ah OK thank you.

I ended up doing like that, the problem is that my hover doesn’t work and I don’t know why?

`<div class="eachCart">` +
                    ` <img src="./img/${productImg}" class="cartImg" alt="">` +
                    `<div class="cartDesc">` +
                    `<h1 class="cartItemName">${productName}</h1>` +
                    `<p class="cartItemPrice">${productPrice}€</p>` +
                    `<i class="fa-solid fa-trash fa-xl" style="color: #000000;" id="remove${id}"></i>` +
                    `</div>` +
                    `</div>`

css code

.eachCart i {
    cursor: pointer;
}

.eachCart i:hover {
    color: red;
    background-color: transparent;
}

You have this rule setting the color:

That rule trumps all external css rules (which is why you should avoid using them like that). The only way to over-ride an inline style is to use !important;

e.g. like this:


.eachCart i:hover {
    color: red!important;
    background-color: transparent;
}