html - 在我的第一个 CSS 网格上工作。网格定位和对象重叠有问题

标签 html css

标题解释了大部分内容。我想要一个覆盖页面底部 40% 的 3x2 网格。我似乎无法移动 div 并且对象重叠。

https://jsfiddle.net/draymon/r7538o2x/3/#&togetherjs=ymVMBJNyuV

    body,
    html {
        height: auto;
        width: auto;
    }

    div {
        position: relative;
        top: 50%;
    }
    .grid-container {
        display: grid;
        height: 40%;
        width: 100%;
        grid-template-columns: repeat(3, auto);
        grid-template-rows: repeat(2, auto);
        position: relative;
    }
    .grid-item {
        border: 1px solid rgb(0, 0, 0);
        position: relative;
    }
    .content {
        position: absolute;
        top: 25%;
        left: 35%;
    }

最佳答案

我建议您看一下 flexbox,我发现它更容易使用。您可以在此处阅读更多信息:https://css-tricks.com/snippets/css/a-guide-to-flexbox/

相信我,它比 css 网格简单多了

希望这能解决您的问题<3

关于html - 在我的第一个 CSS 网格上工作。网格定位和对象重叠有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57932198/

相关文章:

php - 使用 php 获取行/列中的数据

html - 有什么方法可以为超过(例如)10 个字母的单词设置函数吗?

jquery - 如何将类添加到列表项并将其从上一项中删除

javascript - 如何使按钮宽度跟随基于文本的最大宽度按钮?

jquery - 如何防止在下拉菜单中单击时失去焦点

jquery - 如何平滑背景图像的移动?

javascript - 如何在包含div的ul中使用jquery索引?

html - 当网格项没有任何同级项时,它会占用全屏宽度

html - 证明其他元素而不是文本

html - IE7 位置绝对与 margin 自动错误