SCSS Nested Structure Conversion

User
.img-acc .accordion {
width: 100%;
height: 695px;
overflow: hidden;
margin: auto;
border: none;
border-top: transparent !important;
border-bottom: transparent !important;
}

.img-acc .accordion ul {
width: 100%;
display: flex;
gap: 16px;
table-layout: fixed;
margin: 0;
padding: 0;
}

.img-acc .accordion ul li {
display: table-cell;
vertical-align: bottom;
position: relative;
width: 16.666%;
height: 540px;
background-repeat: no-repeat;
background-position: center center;
transition: all 500ms ease;
background-size: cover;
}

.img-acc .accordion ul li div {
display: block;
overflow: visible;
width: 100%;
}

.img-acc .accordion ul li div a {
display: block;
height: 540px;
width: 100%;
position: relative;
z-index: 3;
box-sizing: border-box;
color: $color-white;
text-decoration: none;
font-family: $font-regular;
transition: all 200ms ease;
}

.img-acc .accordion ul li.normala div a * {
opacity: 0;
margin: 0;
width: 100%;
text-overflow: ellipsis;
position: relative;
z-index: 5;
white-space: nowrap;
overflow: hidden;
-webkit-transform: translateX(-20px);
transform: translateX(-20px);
-webkit-transition: all 400ms ease;
transition: all 400ms ease;
}

.img-acc .accordion ul li div a p,
.img-acc .accordion ul li div a .button {
bottom: -118px;
top: auto;
position: absolute;
color: rgb(var(–color-heading));
}

.image-content-wrapper .slide-content {
padding: 24px;
}

.img-acc .accordion ul li div a .button {
bottom: -78px;
width: fit-content;
line-height: inherit;
}

.clickcontent h3 {
position: absolute;
left: 32px;
bottom: 32px;
}

.img-acc .accordion ul li:nth-child(1) {
width: 60%;
}

.img-acc .accordion ul li.normala a {
background: rgba($color-black, 0.4);
}

.img-acc .accordion ul:hover li.normalhover:hover a {
background: rgba($color-black, 0);
}

.img-acc .accordion ul:hover li.normalhover:hover a * {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}

.arrow.right-arrow {
position: absolute;
right: 0;
transform: translate(50px, -50px);
top: 50%;
}

.arrow.left-arrow {
position: absolute;
left: 0;
top: 50%;
transform: translate(-50px, -50px);
}

li.normalhover {
border-radius: 5px;
}
.swiperslidesOverview {
display: none;
}

.acc-items-swiper .slide-content h3 {
top: -48px;
position: absolute;
margin: 0;
font-size: 1.5rem;
color: $color-white;
}

@media screen and (max-width: 767px) {
.img-acc .accordion {
height: auto;
}

.img-acc .arrow {
display: none;
}

.img-acc .accordion ul li,
.img-acc .accordion ul li.normalhover:hover,
.img-acc .accordion ul:hover li,
.img-acc .accordion ul:hover li.normalhover:hover {
position: relative;
display: table;
table-layout: fixed;
width: 100%;
-webkit-transition: none;
transition: none;
}
.img-acc {
display: none;
}

.swiperslidesOverview {
display: block;
}
}
convert above scss in nested

Assistant
Here's your SCSS converted into a properly nested structure:

.img-acc {
    .accordion {
        width: 100%;
        height: 695px;
        overflow: hidden;
        margin: auto;
        border: none;
        border-top: transparent !important;
        border-bottom: transparent !important;

        ul {
            width: 100%;
            display: flex;
            gap: 16px;
            table-layout: fixed;
            margin: 0;
            padding: 0;

            li {
                display: table-cell;
                vertical-align: bottom;
                position: relative;
                width: 16.666%;
                height: 540px;
                background-repeat: no-repeat;
                background-position: center center;
                transition: all 500ms ease;
                background-size: cover;

                div {
                    display: block;
                    overflow: visible;
                    width: 100%;

                    a {
                        display: block;
                        height: 540px;
                        width: 100%;
                        position: relative;
                        z-index: 3;
                        box-sizing: border-box;
                        color: $color-white;
                        text-decoration: none;
                        font-family: $font-regular;
                        transition: all 200ms ease;

                        p,
                        .button {
                            bottom: -118px;
                            top: auto;
                            position: absolute;
                            color: rgb(var(--color-heading));
                        }

                        .button {
                            bottom: -78px;
                            width: fit-content;
                            line-height: inherit;
                        }
                    }
                }

                &.normala {
                    div {
                        a {
                            * {
                                opacity: 0;
                                margin: 0;
                                width: 100%;
                                text-overflow: ellipsis;
                                position: relative;
                                z-index: 5;
                                white-space: nowrap;
                                overflow: hidden;
                                transform: translateX(-20px);
                                transition: all 400ms ease;
                            }
                        }
                    }

                    a {
                        background: rgba($color-black, 0.4);
                    }
                }

                &:nth-child(1) {
                    width: 60%;
                }
            }

            &:hover {
                li {
                    &.normalhover {
                        &:hover {
                            a {
                                background: rgba($color-black, 0);

                                * {
                                    opacity: 1;
                                    transform: translateX(0);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

.image-content-wrapper {
    .slide-content {
        padding: 24px;
    }
}

.clickcontent {
    h3 {
        position: absolute;
        left: 32px;
        bottom: 32px;
    }
}

.arrow {
    &.right-arrow {
        position: absolute;
        right: 0;
        transform: translate(50px, -50px);
        top: 50%;
    }

    &.left-arrow {
        position: absolute;
        left: 0;
        top: 50%;
        transform: translate(-50px, -50px);
    }
}

li.normalhover {
    border-radius: 5px;
}

.swiperslidesOverview {
    display: none;
}

.acc-items-swiper {
    .slide-content {
        h3 {
            top: -48px;
            position: absolute;
            margin: 0;
            font-size: 1.5rem;
            color: $color-white;
        }
    }
}

@media screen and (max-width: 767px) {
    .img-acc {
        .accordion {
            height: auto;

            ul {
                li,
                & li.normalhover:hover,
                &:hover li,
                &:hover li.normalhover:hover {
                    position: relative;
                    display: table;
                    table-layout: fixed;
                    width: 100%;
                    transition: none;
                }
            }
        }

        .arrow {
            display: none;
        }

        display: none;
    }

    .swiperslidesOverview {
        display: block;
    }
}

This version is fully nested, making it easier to maintain and understand. Let me know if you need further refinements! ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *