需要帮助使用网格CSS创建此响应式堆叠卡的外观。下面的代码
我正在尝试使用CSS网格来实现此堆叠卡容器。我知道网格可能很难,因为他们的属性有很多了解。最终堆叠的卡将是3行,希望使用
`grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));`
我想但是,使用网格而不是使用Display创建幻觉:绝对和使用顶部/底部或负距离。 想法是在此处使用网格来创建此故障:
我的 知道我如何使用网格容器来实现第二张图片(被堆叠的卡片幻觉)?侧卡在右侧,底部卡在主卡的底部?
以下是我的启动代码,我正在使用React.js:
<div className={classes.outerCard}>
<div className={classes.mainCard}>
<h2 className={classes.title}>{title}</h2>
</div>
<div className={classes.sideCard}></div>
<div className={classes.bottomCard}>
<h5 className={classes.subtitle}>{subtitle}</h5>
</div>
</div>
请让我知道您的想法或网格知识!任何事情都会有所帮助。似乎
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
是保持其响应迅速而没有任何媒体查询的最佳选择,它将设置一个网格容器,在这种情况下,它具有灵活数量的列数,然后将3列尽可能长,然后分解为2列,然后最终只有移动的一行。
I'm trying to achieve this stacked card container using CSS Grid. I know Grid can be hard being that there is so much to know about their properties. The final stacked card will be 3 rows and be responsive hopefully using
`grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));`
I want to however create an illusion using Grid instead of using display: absolute and using top/bottom or negative margins. My idea is to use Grid to create this breakdown here:
Illusion of stacked card using grid
Does anyone know how I can achieve the second picture (illusion of the cards being stacked) using the Grid container? Where the side card is on the right and the bottom card is at the bottom of the Main Card?
Below is my start up code, I am using React.js:
<div className={classes.outerCard}>
<div className={classes.mainCard}>
<h2 className={classes.title}>{title}</h2>
</div>
<div className={classes.sideCard}></div>
<div className={classes.bottomCard}>
<h5 className={classes.subtitle}>{subtitle}</h5>
</div>
</div>
Please let me know your ideas or Grid knowledge! Anything will be helpful. It seems like
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
is the best option to keep it being responsive without any media queries, that will set up a grid container that has a flexible number of columns in this case keep 3 columns as long as possible before breaking into 2 columns and then eventually just a row for mobile.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用Grid,您需要为所有DIV指定开始/端列和行,因为它们具有突出边缘的方式。您将需要的最小行数为5。我设置了估计的固定列和粗糙尺寸以匹配您的图像;您必须进行调整才能使他们响应迅速。
With grid you will need to specify the start/end columns and rows for all of the divs because of the way they have jutting edges. The minimum number of rows and columns you will need is 5 each. I set estimated fixed column and rough dimensions to match your image; you'll have to adjust in order for them to be responsive.