html - CSS/Sass 网格间隙没有响应

标签 html css css-grid

我的网格系统无法正常工作,我的容器堆叠在一起,而不是 3 行的网格系统。

我有这个造型:

.container {
    display: grid;
    margin: auto;
    width: 65%;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 0rem;
    justify-items: center;
}

.topic {
    position: relative;
    width: 350px;
    height: 170px;
    border: 1px solid rgb(214, 214, 214);
    background: white;
    padding: 1rem;
    text-align: left;
    border-radius: 10px;
    cursor: pointer;
    color: black;
    box-shadow: 2px 1px 1px 1px rgb(228, 228, 228);

    hr {
        color: white;
        text-decoration: none;
    }

    h3 {
        color: black;
        padding-bottom: 4%;
    }

    p {
        color: black;
        padding-top: 20px;
    }

    #count {
        position: absolute;
        bottom: 5%;
        right: 5%;
        font-size: 13px;

    }
}

用这个 html

<template>
  <div class="container">
    <router-link to="/">
      <div class="topic" v-for="topic in topics" :key="topic.id">
        <h3>{{ topic.description }}</h3>
        <hr />
        <p id="count">Completed: 0/17</p>
      </div>
    </router-link>
  </div>
</template>

在我决定在我的容器周围放置一个路由器链接之前,我已经完成了所有工作,所以这是我问题的根源,但我当然希望保持这种方式并且内部没有小链接。

最佳答案

您正在迭代您的 <div> <router-link> 内的元素元素,所以它们都在第一列内结束。如果这不可能,请原谅我,因为我对 Vue 不是很熟悉,但你就不能

<template>
    <div class="container">
        <router-link to="/" v-for="topic in topics" >
            <div class="topic" :key="topic.id">
                <h3>{{ topic.description }}</h3>
                <hr />
                <p id="count">Completed: 0/17</p>
            </div>
        </router-link>
    </div>
</template>

关于html - CSS/Sass 网格间隙没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57436980/

相关文章:

html - 所有宽度设置为最宽元素的宽度

html - 使用 YUI CSS 重置时在 <ul> 上显示默认浏览器元素符号点

javascript - 如何在 JQuery 中获取选定的列表属性

html - CSS设置背景白色

javascript - 动态删除伪 css 类

html - 仅CSS的砌体布局

html - 为什么我的第一个对象比网格 CSS 中的其他对象大

html - 如何使用纯 css 在按钮悬停时显示按钮内的字符串?

javascript - 应用于多个元素时仅触发一次事件

CSS - 如何对齐这些元素?