Home > other >  Why don't my elements inside the div become horizontally scrollable?
Why don't my elements inside the div become horizontally scrollable?

Time:08-21

Inside my HTML:

<div >
        <button >&#8656;</button>
        <div >
            <ul >
                <li  data-active>
                    <img src="images/img1.png" alt="Certificate Image #1">
                    <p>lorem10</p>
                    <p>2022</p>
                </li>
                <li >
                    <img src="images/img2.png" alt="Certificate Image #2">
                    <p>Lorem10</p>
                    <p>2022</p>
                </li>
                <li >
                    <img src="images/img3.png" alt="Certificate Image #3">
                    <p>lorem10</p>
                    <p>2022</p>
                </li>
            </ul>
        </div>
    </div>

Inside my scss;

.certificates-container{
    position: fixed;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;

    .certificates-exit-btn{
        position: absolute;
        top: 20px;
        right: 20px;
        font-size: 1em;
        padding: 0.5em 1em;
    }

    .carousel{
        display: block;
        .carousel-list{
            border: 1px solid blue;
            padding: 2em;
            display: flex;
            overflow-y: scroll;
            .slide{
                border: 1px solid green;
                width: 400px;
                img{
                    display: block;
                    width: 100%;
                }
                p{
                    text-align: center;
                }
            }
        }
    }
}

I want .carousel-list to be horizontally scrollable. But green bordered .slide elements overflows the container and become invisible and looks like this; image It does not become horizontally scrollable they just overflows the container and i can't put certain pixel width to them. How should I do that?

CodePudding user response:

overflow-y property specifies whether to clip the content, add a scroll bar, or display overflow content of a block-level element when it overflows at the top and bottom edges. You need to use overflow-x for this.

CodePudding user response:

Add this

.carousel-list {
    overflow-x: scroll;
}
  • Related