Html 在居中悬停时显示缩略图标题

Html 在居中悬停时显示缩略图标题,html,css,hover,caption,Html,Css,Hover,Caption,我试图在悬停中心显示一个缩略图标题:水平和垂直对齐,但没有成功 在小提琴中,您可以看到一个带有悬停标题的响应性缩略图网格。我给了它一个红色的虚线边框,所以你可以看到它和缩略图的大小不一样。我无法使标题标题在缩略图中居中。也许我的缩略图网格需要不同的构建。希望有人能帮助我 试试这个 .thumb:hover{border:1px dashed red;background-color:red;} .caption { position: absolute; top:40%; left:0; /

我试图在悬停中心显示一个缩略图标题:水平和垂直对齐,但没有成功

在小提琴中,您可以看到一个带有悬停标题的响应性缩略图网格。我给了它一个红色的虚线边框,所以你可以看到它和缩略图的大小不一样。我无法使标题标题在缩略图中居中。也许我的缩略图网格需要不同的构建。希望有人能帮助我

试试这个

.thumb:hover{border:1px dashed red;background-color:red;}

.caption {
position: absolute;
top:40%;
left:0;
/*border: dashed 1px red;*/ //remove it
width:100%;
/*height:100%;*/ // remove it
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
 transition: all 0.3s;
 }
小提琴:

试试这个

.thumb:hover{border:1px dashed red;background-color:red;}

.caption {
position: absolute;
top:40%;
left:0;
/*border: dashed 1px red;*/ //remove it
width:100%;
/*height:100%;*/ // remove it
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
 transition: all 0.3s;
 }
小提琴:

试试这个

.thumb:hover{border:1px dashed red;background-color:red;}

.caption {
position: absolute;
top:40%;
left:0;
/*border: dashed 1px red;*/ //remove it
width:100%;
/*height:100%;*/ // remove it
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
 transition: all 0.3s;
 }
小提琴:

试试这个

.thumb:hover{border:1px dashed red;background-color:red;}

.caption {
position: absolute;
top:40%;
left:0;
/*border: dashed 1px red;*/ //remove it
width:100%;
/*height:100%;*/ // remove it
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
 transition: all 0.3s;
 }
小提琴:参见这里的小提琴: 并添加css:

.caption h3 {
    margin-top: 59px;
}
请看这里的小提琴: 并添加css:

.caption h3 {
    margin-top: 59px;
}
请看这里的小提琴: 并添加css:

.caption h3 {
    margin-top: 59px;
}
请看这里的小提琴: 并添加css:

.caption h3 {
    margin-top: 59px;
}

您可以简单地将标题包装在另一个div中,并使用transate(当然是所有前缀)将其居中,也可以简单地使用表格(表格+表格单元格)将其居中
,将鼠标悬停在第一个

.insideCap{
  background: red;
  top: 50%;
  position: absolute;
  width: 100%;
  transform: translateY(-50%);
}
其他方式:

parent{
  dispaly:table;
}
son{
  display: table-cell;
  vertical-align: middle;
}

您可以简单地将标题包装在另一个div中,并使用transate(当然是所有前缀)将其居中,也可以简单地使用表格(表格+表格单元格)将其居中
,将鼠标悬停在第一个

.insideCap{
  background: red;
  top: 50%;
  position: absolute;
  width: 100%;
  transform: translateY(-50%);
}
其他方式:

parent{
  dispaly:table;
}
son{
  display: table-cell;
  vertical-align: middle;
}

您可以简单地将标题包装在另一个div中,并使用transate(当然是所有前缀)将其居中,也可以简单地使用表格(表格+表格单元格)将其居中
,将鼠标悬停在第一个

.insideCap{
  background: red;
  top: 50%;
  position: absolute;
  width: 100%;
  transform: translateY(-50%);
}
其他方式:

parent{
  dispaly:table;
}
son{
  display: table-cell;
  vertical-align: middle;
}

您可以简单地将标题包装在另一个div中,并使用transate(当然是所有前缀)将其居中,也可以简单地使用表格(表格+表格单元格)将其居中
,将鼠标悬停在第一个

.insideCap{
  background: red;
  top: 50%;
  position: absolute;
  width: 100%;
  transform: translateY(-50%);
}
其他方式:

parent{
  dispaly:table;
}
son{
  display: table-cell;
  vertical-align: middle;
}

我在标题中添加了一个内部div,并将其边距高度设置为25%。删除媒体查询中宽度非常小的页边距

    <div class="caption">
          <div class="inner-caption">
              <h3>Untitled for now</h3>
              <p>Caption</p>
          </div>
    </div>

我在标题中添加了一个内部div,并将其边距高度设置为25%。删除媒体查询中宽度非常小的页边距

    <div class="caption">
          <div class="inner-caption">
              <h3>Untitled for now</h3>
              <p>Caption</p>
          </div>
    </div>

我在标题中添加了一个内部div,并将其边距高度设置为25%。删除媒体查询中宽度非常小的页边距

    <div class="caption">
          <div class="inner-caption">
              <h3>Untitled for now</h3>
              <p>Caption</p>
          </div>
    </div>

我在标题中添加了一个内部div,并将其边距高度设置为25%。删除媒体查询中宽度非常小的页边距

    <div class="caption">
          <div class="inner-caption">
              <h3>Untitled for now</h3>
              <p>Caption</p>
          </div>
    </div>
您可以尝试以下方法:
HTML:
添加此div:
CSS:
在您的样式中添加此css:
.标题文字{
左:0;
位置:绝对位置;
右:0;
最高:32%;
}   
请参见

,您可以尝试以下方法:
HTML:
添加此div:
CSS:
在您的样式中添加此css:
.标题文字{
左:0;
位置:绝对位置;
右:0;
最高:32%;
}   
请参见

,您可以尝试以下方法:
HTML:
添加此div:
CSS:
在您的样式中添加此css:
.标题文字{
左:0;
位置:绝对位置;
右:0;
最高:32%;
}   
请参见

,您可以尝试以下方法:
HTML:
添加此div:
CSS:
在您的样式中添加此css:
.标题文字{
左:0;
位置:绝对位置;
右:0;
最高:32%;
}   
请参见

仅通过更改高度并向标题类添加填充

.caption {
position: absolute;
padding-top:25%;
top:0;
left:0;
border: dashed 1px red;
width:100%;
height:60%;
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}

仅通过更改高度并向标题类添加填充

.caption {
position: absolute;
padding-top:25%;
top:0;
left:0;
border: dashed 1px red;
width:100%;
height:60%;
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}

仅通过更改高度并向标题类添加填充

.caption {
position: absolute;
padding-top:25%;
top:0;
left:0;
border: dashed 1px red;
width:100%;
height:60%;
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}

仅通过更改高度并向标题类添加填充

.caption {
position: absolute;
padding-top:25%;
top:0;
left:0;
border: dashed 1px red;
width:100%;
height:60%;
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}


谢谢,但它不是真正居中的,40%居中,但在标题中使用背景色时,是否可以完全覆盖缩略图大小?请查看我的更新答案以了解拇指悬停背景色。提琴:谢谢,但它不是真正居中的,它是居中的,但当使用标题的背景色完全覆盖缩略图大小时,有可能吗?请查看我的更新答案以了解拇指悬停背景色。提琴:谢谢,但它不是真正居中的,它是居中的,但当使用标题的背景色完全覆盖缩略图大小时,有可能吗?请查看我的更新答案以了解拇指悬停背景色。提琴:谢谢,但它不是真正居中的,它是居中的,但当使用标题的背景色完全覆盖缩略图大小时,有可能吗?请查看我的更新答案以了解拇指悬停背景色。小提琴手:谢谢你的作品最好!是否可以删除标题的外缘,以便在使用背景色时,其大小与缩略图相同?我能想到的最好方法是将图像作为缩略图的背景,高度、宽度为100%。然后删除悬停时的背景。我想这就是你想要的。谢谢,但是缩略图下面还有一些空间,现在它会把缩略图推到它下面。谢谢,你的效果最好!是否可以删除标题的外缘,以便在使用背景色时,其大小与缩略图相同?我能想到的最好方法是将图像作为缩略图的背景,高度、宽度为100%。然后删除悬停时的背景。我想这就是你想要的。谢谢,但是缩略图下面还有一些空间,现在它会把缩略图推到它下面。谢谢,你的效果最好!是否可以删除标题的外缘,以便在使用背景色时,其大小与缩略图相同?我能想到的最好方法是将图像作为缩略图的背景,高度、宽度为100%。然后删除悬停时的背景。我想这就是你想要的。谢谢,但是缩略图下面还有一些空间,现在它会把缩略图推到它下面。谢谢,你的效果最好!是否可以删除标题的外缘,以便在使用背景色时,其大小与缩略图相同?我能想到的最好方法是将图像作为缩略图的背景,高度、宽度为100%。然后移除ba