Css 如何使此覆盖覆盖整个缩略图

Css 如何使此覆盖覆盖整个缩略图,css,Css,因此,我想在鼠标悬停时覆盖整个缩略图,以便覆盖内容填充整个图像,100%乘以100%。因此,覆盖层应该只覆盖图像(图像的整个大小),而不是超过这个范围 以下是演示当前状态的笔: 。关于图像{ 最大宽度:800px; 保证金:0自动; } .关于{ 边缘顶部:60像素; } .关于内部img{ 最大宽度:100%; 右边距:20px; } .关于.关于{ 位置:相对位置; 溢出:隐藏; } .about.about\u-inner.about\u-inner-覆盖{ 背景:rgba(0,0,0,7

因此,我想在鼠标悬停时覆盖整个缩略图,以便覆盖内容填充整个图像,100%乘以100%。因此,覆盖层应该只覆盖图像(图像的整个大小),而不是超过这个范围

以下是演示当前状态的笔:

。关于图像{
最大宽度:800px;
保证金:0自动;
}
.关于{
边缘顶部:60像素;
}
.关于内部img{
最大宽度:100%;
右边距:20px;
}
.关于.关于{
位置:相对位置;
溢出:隐藏;
}
.about.about\u-inner.about\u-inner-覆盖{
背景:rgba(0,0,0,75);
文本对齐:居中;
填充:45px 0 66px 0;
不透明度:0;
过渡:不透明度。25秒缓解;
}
.about.about\u-inner:悬停.about\u-inner--覆盖{
不透明度:1;
}
洛勒姆

洛勒姆

洛勒姆


您需要使用
绝对
定位和调整框的大小。您可以使用coordonates调整框的大小,使其适合任何大小,因为您已经在
relative
positioning中设置了父项

.about .about__inner .about__inner--overlay {
  background: rgba(0, 0, 0, .75);
  text-align: center;
  padding: 45px 0 66px 0;
  opacity: 0;
  transition: opacity .25s ease;
  top:0;
  left:15px;
  right:15px;
  bottom:0;
  color:white;
  position:absolute
}
。关于图像{
最大宽度:800px;
保证金:0自动;
}
.关于{
边缘顶部:60像素;
}
.关于内部img{
最大宽度:100%;
右边填充:20px;
}
.关于.关于{
位置:相对位置;
溢出:隐藏;
}
.about.about\u-inner.about\u-inner-覆盖{
背景:rgba(0,0,0,75);
文本对齐:居中;
填充:45px 0 66px 0;
不透明度:0;
过渡:不透明度。25秒缓解;
排名:0;
左:15px;
右:35px;
底部:0;
颜色:白色;
位置:绝对位置
}
.about.about\u-inner:悬停.about\u-inner--覆盖{
不透明度:1;
}

洛勒姆

洛勒姆

洛勒姆


您需要使用
绝对
定位和调整框的大小。您可以使用coordonates调整框的大小,使其适合任何大小,因为您已经在
relative
positioning中设置了父项

.about .about__inner .about__inner--overlay {
  background: rgba(0, 0, 0, .75);
  text-align: center;
  padding: 45px 0 66px 0;
  opacity: 0;
  transition: opacity .25s ease;
  top:0;
  left:15px;
  right:15px;
  bottom:0;
  color:white;
  position:absolute
}
。关于图像{
最大宽度:800px;
保证金:0自动;
}
.关于{
边缘顶部:60像素;
}
.关于内部img{
最大宽度:100%;
右边填充:20px;
}
.关于.关于{
位置:相对位置;
溢出:隐藏;
}
.about.about\u-inner.about\u-inner-覆盖{
背景:rgba(0,0,0,75);
文本对齐:居中;
填充:45px 0 66px 0;
不透明度:0;
过渡:不透明度。25秒缓解;
排名:0;
左:15px;
右:35px;
底部:0;
颜色:白色;
位置:绝对位置
}
.about.about\u-inner:悬停.about\u-inner--覆盖{
不透明度:1;
}

洛勒姆

洛勒姆

洛勒姆


您离它很近了。只需对结构进行一点修改,并在css中添加几行内容:

HTML:


代码笔:

您离它很近。只需对结构进行一点修改,并在css中添加几行内容:

HTML:

代码笔:

试试这个:

.about__inner {
  padding: 0px; //for full frame image
}
.about__inner img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover; //force image display as cover, no scale
}
.about .about__inner .about__inner--overlay {
  position: absolute; //You need it to arrange the div.
  top: 0px;
  left:0px;
  width: 100%;
  height: 100%;
}
试试这个:

.about__inner {
  padding: 0px; //for full frame image
}
.about__inner img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover; //force image display as cover, no scale
}
.about .about__inner .about__inner--overlay {
  position: absolute; //You need it to arrange the div.
  top: 0px;
  left:0px;
  width: 100%;
  height: 100%;
}

你想让覆盖层覆盖整个
。关于\uu inner
还是只覆盖其中图像的大小?@Pangloss我想让它覆盖图像,谢谢你指出,我将编辑问题,因为它是引导式的,布局是有响应的,因此,要考虑大视场和小视场。是否要覆盖整个代码< > AuthIONEng/<代码>或者仅仅是图像中的大小?@ PangRead我希望它能覆盖图像,谢谢你指出,我会编辑问题,因为它是引导的,布局是响应的,因此,考虑两个大的和较小的视口。是的,这正是我想要它做的,但是我想把文本(LoRM)保留在叠加上。是的,

LRORM

应该在图像上是最受欢迎的:)是的,这正是我想要它做的,但是我也想在覆盖上保留文本(LROM)文本。是的,lorem

也应该在图像上方最受欢迎:)
.about__inner {
  padding: 0px; //for full frame image
}
.about__inner img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover; //force image display as cover, no scale
}
.about .about__inner .about__inner--overlay {
  position: absolute; //You need it to arrange the div.
  top: 0px;
  left:0px;
  width: 100%;
  height: 100%;
}
Try this:


.about__images {
  max-width: 800px;
  margin: 0 auto;
}

.about__inner {
  margin-top: 60px;
}

.about__inner img {
  max-width: 100%;
  margin-right: 20px;
}

.about .about__inner {
  position: relative;
  overflow: hidden;
}

.about .about__inner .about__inner--overlay {
  background: rgba(0, 0, 0, .75);
  text-align: center;
  padding: 45px 0 66px 0;
  opacity: 0;
  transition: opacity .25s ease;
}

.about .about__inner:hover .about__inner--overlay {
  opacity: 1;
  position: relative;
  height: 185px;
  top: -185px;
}