简体   繁体   English

CSS - 网格下的空白?

[英]CSS - White space under grid?

I am still learning how to code CSS/HTML and very much a newbie at this.我仍在学习如何编写 CSS/HTML 代码,而且还是个新手。 I created a simple 3 column 1 row grid.我创建了一个简单的 3 列 1 行网格。 I am trying to figure out why there is a white space under my grid.我试图弄清楚为什么我的网格下有一个空白。 It might not show on here via the snippet, but under the CMS I am working with, a huge white space under the grid keeps showing.它可能不会通过片段显示在此处,但在我正在使用的 CMS 下,网格下方的巨大空白区域不断显示。 I don't believe it's any of the other coding as it doesn't happen until I insert this particular code.我不相信这是任何其他编码,因为在我插入这个特定代码之前它不会发生。 Please see coding below.请参阅下面的编码。

 <style type="text/css">.cardcontainer { height: 125vh; width: 100%; display: flex; justify-content: center; }.card { grid-template-columns: repeat(3, 1fr); align-items: center; position: absolute; display: grid; gap: 0 50px; padding: 100px; }.card.card-item { position: relative; }.card img { height: 250px; width: 300px; transition: 0.4s ease-in-out all; }.card.card-details { position: absolute; padding: 10px 5px; bottom: 0px; opacity: 0; transition: 0.4s ease-in-out all; }.card-details h1 { font-size: 18px; color: white; margin: 2px 0; }.card-details p { font-size: 14px; }.card-item:hover.card-details { opacity: 1; bottom: 10px; }.card-item:hover img { transform: scale(1.05); } @media(max-width:600px) {.card { grid-template-columns: 1fr; gap: 0 10px; } </style>
 <div class="cardcontainer"> <div class="card"> <div class="card-item"><img alt="" src="/content/Banana.png" style="width: 400px; height: 300px;" /> <div class="card-details"> <h1>Banana</h1> </div> </div> <div class="card-item"><img alt="" src="/content/Apple.png" style="width: 400px; height: 300px;" /> <div class="card-details"> <h1>Apple</h1> </div> </div> <div class="card-item"><img alt="" src="/content/Oranges.png" style="width: 400px; height: 300px;" /> <div class="card-details"> <h1>Oranges</h1> </div> </div> </div> </div>

This is because of padding: 100px;这是因为padding: 100px; you have added in .card class您已添加.card class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM