itsource

Safari 폭(%) 계산이 잘못됨(부모로부터 1px 필러).

mycopycode 2022. 8. 31. 22:50
반응형

Safari 폭(%) 계산이 잘못됨(부모로부터 1px 필러).

여기에 이미지 설명 입력

여기에 이미지 설명 입력

여기에 이미지 설명 입력

.projects {
        position: relative;
        background-color: black;

        li {
            position: relative;
            width: calc(100% / 3);
            display: inline-block;
            cursor: pointer;
            vertical-align: top;
            overflow: hidden;

            .bg-placeholder {
                position: relative;
                width: 100%;

                img {
                    position: relative;
                    display: block;
                    width: 100%;
                    height: auto !important;
                }
            }

            .bg {
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                left: 0;
                transition: transform cubic-bezier(0.165, 0.84, 0.44, 1) $time;

                img {
                    position: relative;
                    display: block;
                    width: 100%;
                    height: auto !important;
                }
            }

            .gradient {
                position: absolute;
                // width: 100%;
                height: 80%;
                left: -2px;
                right: -1px;
                top: auto;
                bottom: -1px;
                transform: translate3d(0,0,0);
                transition: height cubic-bezier(0.165, 0.84, 0.44, 1) $time;

                img {
                    height: 100%;
                }
            }

            .content {
                position: absolute;
                width: 100%;
                bottom: 0;
                height: 35%;
                text-align: center;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;

                .content-titles {
                    position: relative;
                    text-align: center;
                    width: 98%;
                    z-index: 2;

                    span {
                        font-size: 15px;
                        line-height: 1.4;
                        transition: opacity ease $time;
                        opacity: 0.7;
                        display: inline-block;
                    }
                }

                .content-title {
                    span {
                        font-family: "Gotham-Bold";
                        color: #fff;
                        text-transform: uppercase;
                    }
                }

                .content-sub-title {
                    margin-top: 3px;

                    span {
                        font-family: "Gotham-Book";
                        color: #d5a83d;
                    }
                }
            }

            .cover-up {
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                left: 0;
                // opacity: 0;
                // visibility: hidden;
                // background-color: #000;
                // transition: all ease $time;
                display: flex;
                justify-content: center;
                align-items: center;
                z-index: 3;

                .text {
                    position: relative;
                    width: 100%;
                    text-align: center;
                    transform: translateY(100%);
                    opacity: 0;
                    visibility: hidden;
                    transition: all ease $time;

                    span {
                        display: inline-block;
                        font-family: "Gotham-Light";
                        color: #fff;
                        font-size: 24px;
                        text-transform: uppercase;
                        color: #d5a83d;
                    }
                }
            }

            .desktop &:hover {
                .bg {
                    transform: scale(1.12);
                    transition: all 0.3s ease;
                }

                .gradient {
                    height: 200%;
                    transition: all 0.3s ease;
                }

                .content{
                    .content-titles {
                        span {
                            opacity: 1;
                        }
                    }
                }
                .cover-up {
                    .text {
                        opacity: 1;
                        visibility: visible;
                        transform: translateY(0);
                    }
                }
            }
        }
    }

어떤 상황에서는 프로젝트 돔이 부모에게 -1px offest처럼 보입니다.왜 이런 일이 일어날까요?safari, chrome, ff에서는 정상적으로 동작합니다.

그림 1의 빨간색 배경색은 .projects의 parent dom에 지정한 색상입니다..gradient에서 translate3d(0,0,0)가 주원인이지만, 이 스타일을 삭제하면 호버 효과가 흔들립니다.

제발 도와주세요, 고마워요!

언급URL : https://stackoverflow.com/questions/42434294/safari-percent-width-calculate-wrong-1px-filcker-from-its-parent

반응형