作者:zj5415 | 来源:互联网 | 2023-05-18 06:23
Ihaveacalendarlayoutusingthefollowingcss-gridstyles:我有一个使用以下css-grid样式的“日历”布局:.calenda
I have a 'calendar' layout using the following css-grid styles:
我有一个使用以下css-grid样式的“日历”布局:
.calendar {
display: grid;
grid-template-columns: repeat(7, 1fr);
grid-template-rows: 1.5em 1.5em repeat(6, 1fr);
width: 100%;
height: 100%;
}
(Codepen https://codepen.io/joelhoward0/pen/vJLmWK)
(Codepen https://codepen.io/joelhoward0/pen/vJLmWK)
The first two rows are a 'controls' header and days of the week headers, followed by divs for each day in the month:
前两行是“控件”标题和“星期”标题,然后是“月中的每一天”标题:
Each day has a .header
and .content
div. I want the .header
div to take up 1/5 of the height of the row, and the content to take up 4/5 and scroll if the content overflows.
每天都有.header和.content div。我希望.header div占一行高度的1/5,如果内容溢出,则内容占4/5并滚动。
However, any combination of styles I've tried just leads to .content
growing, shrinking the other grid rows to compensate. I assume this is due to the use of 1fr
on the container grid-template-rows.
但是,我尝试过的任何样式组合都只会导致.content的增长,缩小其他网格行以进行补偿。我认为这是由于在容器网格模板行上使用了1fr。
Is it possible to achieve a max height of 4/5 of the grid row height, which is 1/6 of the vertical space available, on the .content
div?
是否可以在.content div中实现网格行高度的4/5,即垂直空间的1/6 ?
(Note: setting overflow-y: auto;
on .day
achieves what I want, but the header is included in the scrolling area. Setting overflow-y: auto;
on .content
doesn't seem to do anything.)
(注:设置overflow-y:汽车;on .day达到了我想要的效果,但是标题包含在滚动区域中。设置overflow-y:汽车;on .content似乎没有任何作用。
2 个解决方案