Position fixed with vh not working properly on chrome, any assitance?

944 Views Asked by At

I'm having a problem, specifically when I use chrome. I use on my website portfolio a modal element, when users click on it, the modal's background appears only in the upper page taking the whole width. Well I use a 100vh on the modal's bg and set it as position:fixed, and align the modal's content in the center (flex). It works normally in other browsers but not on chrome. Here's a code snippet of the HTML:

<div class="modal-bg">
    <div class="box-container">
        <div class="img-box">
            <img src="">
        </div>
        <div class="caption">
            <p>Some Text here</p>
            <div class="btns">
                <a href="#">btn-1</a>
                <a href="#>btn-2</a>
            </div>
        </div>
    </div>
</div>

Here's a SCSS Snippet:

.modal-bg {
    position: fixed;
    z-index: 999;
    width: 100%;
    height: 100vh;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity 0.5s ease-in;

    .box-container {
        position: relative;
        background-color: #f2f2f2;
        width: 80%;
        height: 60rem;
        max-width: 82rem;
        min-height: 45rem;
        border-radius: 32px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        overflow: hidden;

        .img-box {
            margin: 0 .8rem;
            height: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            
            img {
                max-width: 53rem;
                width: 100%;
            }
        }

        .caption {
            position: relative;
            width: 100%;
            justify-self: flex-end;
            font-size: 1.8rem;
            color: #000000;
            font-weight: normal;
            padding: 2rem;
            background-color: #ffffff;

            .btns {
                width: 100%;
                display: flex;
                justify-content: space-around;
                align-items: center;
                margin: 1rem 0;
                
                a {
                    line-height: 2.4rem;
                    color: black;
                    font-size: 1.4rem;
                    display: flex;
                    text-transform: uppercase;
                    padding: .8rem;
                    background-color: #ffffff;
                }
            }
        }
    }
}
0

There are 0 best solutions below