Get stacked divs to stick to the bottom with CSS Grid(使用CSS网格获得堆叠的div以贴近底部)
问题描述
在下面的布局中,当我将鼠标悬停在上时,我试图使内容在整个框中保持底部对齐,以便单词和副标题保持在它们所在的位置,而显示的 (我确实希望.content框在鼠标悬停时达到容器的完全高度,从而将整个图像变为红色。) 此外...无论我将该规则放在哪个元素上,都无法使 感谢您的帮助或建议! 我尝试了您的代码片段,并进行了重构。删除了不必要的html标记并更改了一些样式选项。<ul>
仅位于其顶部。我正在尽我所能地处理CSS网格--但我不知所措。
数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">
.programbox {
display: grid;
grid-template-areas: 'item';
align-content: end;
justify-content: stretch;
height: 300px;
width: 700px;
background-image: url(https://heroshockey.com/wp2021/wp-content/uploads/2021/07/program-billboards-future-stars.jpg);
background-size: cover;
background-position: 50%;
background-repeat: no-repeat;
}
.programbox::before {
content: '';
grid-area: item;
background-color: red;
mix-blend-mode: multiply;
}
.content {
grid-area: item;
isolation: isolate;
color: white;
align-self: end;
}
.details {
display: none;
}
h1,
p {
margin: 0;
padding: 10px;
}
.programbox:hover .content {
height: 300px;
}
.programbox:hover .details {
display: inherit;
}
<div class="programbox">
<div class="content">
<div class="details">
<ul>
<li>Grades 4 – 8, participants referred by partner schools or social services agencies</li>
<li>Weekly on-ice practices</li>
<li>Learn on-ice skills, confidence building, equipment care</li>
<li>Intro to mentoring relationships with volunteers & HEROS All Stars</li>
</ul>
</div>
<h1 class="header">HEADLINE</h1>
<div class="description">
<p>Subhead</p>
</div>
</div>
</div>
"transition: 1s;"
的悬停过渡变得更慢。推荐答案
.programbox {
height: 300px;
width: 700px;
background-image: url(https://heroshockey.com/wp2021/wp-content/uploads/2021/07/program-billboards-future-stars.jpg);
background-size: cover;
background-position: 50%;
background-repeat: no-repeat;
position: relative;
overflow: hidden;
}
.programbox::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: red;
mix-blend-mode: multiply;
transition: all 1s ease-in-out;
transform: translateY(73%);
}
.programbox:hover::before {
transform: translateY(0%);
}
.content {
height: 100%;
display: grid;
grid-template-rows: 1fr repeat(2, 35px);
overflow: hidden;
isolation: isolate;
color: white;
}
h1,
p,
li {
line-height: 1;
}
.header {
grid-row: 2;
}
.description {
grid-row: 3;
}
.details {
grid-row: 1;
}
.header,
.description {
margin: 0;
padding: 0 10px;
align-self: flex-start;
}
.details {
transform: translateY(100px);
opacity: 0;
user-select: none;
transition: all 0.5s ease-in-out;
}
.programbox:hover .details {
transform: translateY(0);
opacity: 1;
user-select: auto;
transition: all 1.5s ease-in-out;
}
<div class="programbox">
<div class="content">
<h1 class="header">HEADLINE</h1>
<p class="description">Subhead</p>
<ul class="details">
<li>
Grades 4 – 8, participants referred by partner schools or social
services agencies
</li>
<li>Weekly on-ice practices</li>
<li>Learn on-ice skills, confidence building, equipment care</li>
<li>
Intro to mentoring relationships with volunteers HEROS All Stars
</li>
</ul>
</div>
</div>
这篇关于使用CSS网格获得堆叠的div以贴近底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用CSS网格获得堆叠的div以贴近底部
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07