Flexbox在Firefox中显示网格但在Chrome中不显示网格的问题

时间:2019-04-18 15:56:10

标签: css flexbox

我遇到了一个问题,即Firefox按预期显示了6张图像的flexbox网格,但是chrome却根本不显示它们。

CSS的问题部分是“ display:grid;”将其删除后,它会以chrome形式显示,但不会以我想要的方式显示,所有网格项都重叠并伸展,此时Firefox中也会发生同样的情况。

我的CSS如下:

xsl:mode

我的HTML是:

:root {
    /* Base font size */
    font-size: 10px;
}

.flexcontainer {
    max-width: 100rem;
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

.heading {
    font-family: "Roboto", Arial, sans-serif;
    font-size: 2.5rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    padding: 1rem 0;
    color: #005fae;
    text-align: center;
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    /* Compensate for excess margin on outer gallery flex items */
    margin: -1rem -1rem;
}

.gallery-item {
    /* Minimum width of 24rem and grow to fit available space */
    flex: 1 0 24rem;
    /* Margin value should be half of grid-gap value as margins on flex items don't collapse */
    margin: 1rem;
    box-shadow: 0.3rem 0.4rem 0.4rem rgba(0, 0, 0, 0.4);
    overflow: hidden;
    text-align:center;
    position: relative;
}

.gallery-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms ease-out;
}

.centre-text {
    margin: 0 auto;
    font-size: 20px;
    font-family: "Roboto", sans-serif;
    position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
    z-index: 1;
}

.concentration-links {
    color: #fff;
    text-decoration: None;
}

.gallery-image:hover {
    transform: scale(1.15);
}


@supports (display: grid) {
    .gallery {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
        grid-gap: 2rem;
    }

    .gallery,
    .gallery-item {
        margin: 0;
    }
}

该网格本应显示为两行,每行三列,但不显示我想要的方式。

有人对我应该做什么有任何想法吗?

谢谢

0 个答案:

没有答案