Раздел исчезает в Mozilla - PullRequest
       11

Раздел исчезает в Mozilla

2 голосов
/ 25 апреля 2019

У меня есть раздел, который исчезает в Mozilla после определенного медиа-запроса (который влияет только на максимальную ширину flex-direction: 1200px).

Я думаю, это может быть связано с изображениями и их размерами, но я не уверен. Кроме того, я думаю, что мой код плох для того, что я пытаюсь сделать, но это все, что я могу придумать. Так что если вы думаете, какой-нибудь другой лучший способ написать этот раздел, это будет оценено.

.gallery {
    width: 100%;
    color: var(--primary-color);
}


.gallery-container {
    width: 100%;
    padding: 120px 15px 0 15px;
    display: flex;
    position: relative;
}


.gallery-container-text {
    flex: 0 0 33.33%;
    min-width: 33%;
}


.gallery-container-text h2 {
    font-size: 40px;
    padding: 30px 0;
    font-weight: 400;
}


.gallery-container-text h4 {
    font-size: 16px;
    line-height: 1.5;
    padding-right: 30px;
    font-weight: 400;
}


.gallery-container-image {
    flex: 0 0 66.66%;
    min-width: 66%;
    height: 400px;
    max-height: 60vh;
    overflow: hidden;
    position: relative;
    width: 100%;
}
.div-containers {
    position: absolute;
    top: -20px;
    bottom: 0;
    left: -20px;
    right: -20px;
}

.gallery-container-image img {
    box-shadow: 0 5px 23px 0 rgba(0,0,0,.15);
    max-width: 100%;
    height: auto;
}


.gallery-container-image div div:nth-child(1) {
    position: absolute;
    top: 20px;
    left: calc(28.25% + 20px);
    width: 42%;
    -webkit-animation: fadeup .5s ease-in-out .9s;
       -moz-animation: fadeup .5s ease-in-out .9s;
         -o-animation: fadeup .5s ease-in-out .9s;
            animation: fadeup .5s ease-in-out .9s;
    opacity: 0;
    animation-fill-mode: forwards;
}
.gallery-container-image div div:nth-child(2) {
    position: absolute;
    top: calc(27% + 20px);
    left: 20px;
    width: 39%;
    -webkit-animation: fadeup .5s ease-in-out .6s;
       -moz-animation: fadeup .5s ease-in-out .6s;
         -o-animation: fadeup .5s ease-in-out .6s;
            animation: fadeup .5s ease-in-out .6s;
    opacity: 0;
    animation-fill-mode: forwards;
}
.gallery-container-image div div:nth-child(3) {
    position: absolute;
    top: calc(52% + 20px);
    left: calc(22% + 20px);
    width: 54%;
    -webkit-animation: fadeup .5s ease-in-out .3s;
       -moz-animation: fadeup .5s ease-in-out .3s;
         -o-animation: fadeup .5s ease-in-out .3s;
            animation: fadeup .5s ease-in-out .3s;
    opacity: 0;
    animation-fill-mode: forwards;
}
.gallery-container-image div div:nth-child(4) {
    position: absolute;
    top: calc(36% + 20px);
    right: 20px;
    width: 40%;
    -webkit-animation: fadeup .5s ease-in-out;
       -moz-animation: fadeup .5s ease-in-out;
         -o-animation: fadeup .5s ease-in-out;
            animation: fadeup .5s ease-in-out;
    opacity: 0;
    animation-fill-mode: forwards;
}


@keyframes fadeup {
    0% {
        opacity: 0;
        -webkit-transform: translate3d(0, 100%,0);
           -moz-transform: translate3d(0, 100%,0);
             -o-transform: translate3d(0, 100%,0);
                transform: translate3d(0, 100%,0);
    }
    100% {
        opacity: 1;
        -webkit-transform: none;
           -moz-transform: none;
             -o-transform: none;
                transform: none;
    }
}
@media screen and (max-width:1200px) {
    .gallery-container {
        flex-direction: column;
        padding: 30px 15px 0 15px;
    }
    .gallery-container-text {
        flex: 0 0 100%;
        min-width: 100%;
    }
    .gallery-container-text h2 {
        text-align: center;
        padding: 30px 0;
    }
    .gallery-container-text h4 {
        padding-right: 0;
        text-align: center;
        margin-bottom: 30px;
    }
    .gallery-container-image {
        flex: 0 0 100%;
        min-width: 100%;
    }
}
@media screen and (max-width: 600px) {
    .gallery-container-image {
        max-height: 30vh;
    }
}
@media screen and (max-width: 400px) {
    .gallery-container-image {
        max-height: 25vh;
    }
    .gallery-container-text h2 {
        font-size: 30px;
    }
    .gallery-container-text h4 {
        font-size: 14px;
    }
}
<section class="gallery">
    <div class="gallery-container">
        <div class="gallery-container-text">
            <h2>Popular Recipes</h2>
            <h4>Some of our popular recipes with our great selection of Tasties Recipes</h4>
        </div>
        <div class="gallery-container-image">
            <div class="div-containers">
                    <div>
                            <img width="446" height="295" src="https://i.imgur.com/6m3Yrou.jpg" alt="image">
                        </div>
                        <div>
                            <img width="412" height="456" src="https://i.imgur.com/mWYieLP.jpg" alt="image">
                        </div>
                        <div>
                            <img width="572" height="416" src="https://i.imgur.com/sfQ5PyR.jpg" alt="image">
                        </div>
                        <div>
                            <img width="434" height="444" src="https://i.imgur.com/Ug7kH7b.jpg" alt="image">
                        </div>
            </div>
            
        </div>
    </div>
</section>

1 Ответ

1 голос
/ 25 апреля 2019

Ваша проблема в использовании "flex: 0 0 100%;" в ".gallery-container-image", оно должно "flex: 0 0 auto; в блоке" @media screen and (max-width:1200px) {} ".

.gallery {
    width: 100%;
    color: var(--primary-color);
}


.gallery-container {
    width: 100%;
    padding: 120px 15px 0 15px;
    display: flex;
    position: relative;
}


.gallery-container-text {
    flex: 0 0 33.33%;
    min-width: 33%;
}


.gallery-container-text h2 {
    font-size: 40px;
    padding: 30px 0;
    font-weight: 400;
}


.gallery-container-text h4 {
    font-size: 16px;
    line-height: 1.5;
    padding-right: 30px;
    font-weight: 400;
}


.gallery-container-image {
    flex: 0 0 66.66%;
    min-width: 66%;
    height: 400px;
    max-height: 60vh;
    overflow: hidden;
    position: relative;
    width: 100%;
}
.div-containers {
    position: absolute;
    top: -20px;
    bottom: 0;
    left: -20px;
    right: -20px;
}

.gallery-container-image img {
    box-shadow: 0 5px 23px 0 rgba(0,0,0,.15);
    max-width: 100%;
    height: auto;
}


.gallery-container-image div div:nth-child(1) {
    position: absolute;
    top: 20px;
    left: calc(28.25% + 20px);
    width: 42%;
    -webkit-animation: fadeup .5s ease-in-out .9s;
       -moz-animation: fadeup .5s ease-in-out .9s;
         -o-animation: fadeup .5s ease-in-out .9s;
            animation: fadeup .5s ease-in-out .9s;
    opacity: 0;
    animation-fill-mode: forwards;
}
.gallery-container-image div div:nth-child(2) {
    position: absolute;
    top: calc(27% + 20px);
    left: 20px;
    width: 39%;
    -webkit-animation: fadeup .5s ease-in-out .6s;
       -moz-animation: fadeup .5s ease-in-out .6s;
         -o-animation: fadeup .5s ease-in-out .6s;
            animation: fadeup .5s ease-in-out .6s;
    opacity: 0;
    animation-fill-mode: forwards;
}
.gallery-container-image div div:nth-child(3) {
    position: absolute;
    top: calc(52% + 20px);
    left: calc(22% + 20px);
    width: 54%;
    -webkit-animation: fadeup .5s ease-in-out .3s;
       -moz-animation: fadeup .5s ease-in-out .3s;
         -o-animation: fadeup .5s ease-in-out .3s;
            animation: fadeup .5s ease-in-out .3s;
    opacity: 0;
    animation-fill-mode: forwards;
}
.gallery-container-image div div:nth-child(4) {
    position: absolute;
    top: calc(36% + 20px);
    right: 20px;
    width: 40%;
    -webkit-animation: fadeup .5s ease-in-out;
       -moz-animation: fadeup .5s ease-in-out;
         -o-animation: fadeup .5s ease-in-out;
            animation: fadeup .5s ease-in-out;
    opacity: 0;
    animation-fill-mode: forwards;
}


@keyframes fadeup {
    0% {
        opacity: 0;
        -webkit-transform: translate3d(0, 100%,0);
           -moz-transform: translate3d(0, 100%,0);
             -o-transform: translate3d(0, 100%,0);
                transform: translate3d(0, 100%,0);
    }
    100% {
        opacity: 1;
        -webkit-transform: none;
           -moz-transform: none;
             -o-transform: none;
                transform: none;
    }
}
@media screen and (max-width:1200px) {
    .gallery-container {
        flex-direction: column;
        padding: 30px 15px 0 15px;
    }
    .gallery-container-text {
        flex: 0 0 100%;
        min-width: 100%;
    }
    .gallery-container-text h2 {
        text-align: center;
        padding: 30px 0;
    }
    .gallery-container-text h4 {
        padding-right: 0;
        text-align: center;
        margin-bottom: 30px;
    }
    .gallery-container-image {
        flex: 0 0 auto; /* Key line */
        min-width: 100%;
    }
}
@media screen and (max-width: 600px) {
    .gallery-container-image {
        max-height: 30vh;
    }
}
@media screen and (max-width: 400px) {
    .gallery-container-image {
        max-height: 25vh;
    }
    .gallery-container-text h2 {
        font-size: 30px;
    }
    .gallery-container-text h4 {
        font-size: 14px;
    }
}
<section class="gallery">
    <div class="gallery-container">
        <div class="gallery-container-text">
            <h2>Popular Recipes</h2>
            <h4>Some of our popular recipes with our great selection of Tasties Recipes</h4>
        </div>
        <div class="gallery-container-image">
            <div class="div-containers">
                    <div>
                            <img width="446" height="295" src="https://i.imgur.com/6m3Yrou.jpg" alt="image">
                        </div>
                        <div>
                            <img width="412" height="456" src="https://i.imgur.com/mWYieLP.jpg" alt="image">
                        </div>
                        <div>
                            <img width="572" height="416" src="https://i.imgur.com/sfQ5PyR.jpg" alt="image">
                        </div>
                        <div>
                            <img width="434" height="444" src="https://i.imgur.com/Ug7kH7b.jpg" alt="image">
                        </div>
            </div>
            
        </div>
    </div>
</section>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...