Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在图像悬停时进行覆盖_Html_Css_Overlay - Fatal编程技术网

Html 如何在图像悬停时进行覆盖

Html 如何在图像悬停时进行覆盖,html,css,overlay,Html,Css,Overlay,所以,我有一个画廊,里面有一些照片。我想在图像悬停时显示一些人的信息,人的名字和他们的角色 .gallery{ 位置:相对位置; 填充:6px 6px; 浮动:左; 宽度:24.99999%; } .国旗{ 边框:1px实心#ccc; 填充物:5px; } .flag img{ 显示:块; 宽度:100%; 高度:自动; } .生物数据{ 位置:绝对位置; 底部:0; 左:0; 右:0; 溢出:隐藏; 颜色:白色; 宽度:100%; 身高:0; 过渡:放松; } 他的名字是他的工作 见此 C

所以,我有一个画廊,里面有一些照片。我想在图像悬停时显示一些人的信息,人的名字和他们的角色

.gallery{
位置:相对位置;
填充:6px 6px;
浮动:左;
宽度:24.99999%;
}
.国旗{
边框:1px实心#ccc;
填充物:5px;
}
.flag img{
显示:块;
宽度:100%;
高度:自动;
}
.生物数据{
位置:绝对位置;
底部:0;
左:0;
右:0;
溢出:隐藏;
颜色:白色;
宽度:100%;
身高:0;
过渡:放松;
}

他的名字是他的工作
见此

CSS

使用此代码:

 <!DOCTYPE html>
    <html>
      <head>
        <style>
        .container {
          position: relative;
          width: 50%;
        }
        .image {
          display: block;
          width: 100%;
          height: auto;
        }
        .overlay {
          position: absolute;
          bottom: 100%;
          left: 0;
          right: 0;
          background-color: #008CBA;
          overflow: hidden;
          width: 100%;
          height:0;
          transition: .5s ease;

        }
        .container:hover .overlay {
          bottom: 0;
          height: 100%;

        }

        .text {

          white-space: nowrap; 
          color: white;
          font-size: 20px;
          position: absolute;
          overflow: hidden;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          -ms-transform: translate(-50%, -50%);

        }
        </style>
      </head>
      <body>
        <div class="container">
      <img src="https://upload.wikimedia.org/wikipedia/commons/8/83/Shaki_Waterfall2.jpg" alt="Avatar" class="image">
      <div class="overlay">
        <div class="text">
        <p style="padding:20px;">I am Mr. Alven</p>
      </div>
      </div>
    </div>
      </body>
    </html>

.集装箱{
位置:相对位置;
宽度:50%;
}
.形象{
显示:块;
宽度:100%;
高度:自动;
}
.覆盖{
位置:绝对位置;
底部:100%;
左:0;
右:0;
背景色:#008CBA;
溢出:隐藏;
宽度:100%;
身高:0;
过渡:放松;
}
.container:悬停。覆盖{
底部:0;
身高:100%;
}
.文本{
空白:nowrap;
颜色:白色;
字体大小:20px;
位置:绝对位置;
溢出:隐藏;
最高:50%;
左:50%;
转换:翻译(-50%,-50%);
-ms转换:翻译(-50%,-50%);
}
我是阿尔文先生


下面是更新的代码段

.gallery{
位置:相对位置;
填充:6px 6px;
浮动:左;
宽度:24.99999%;
}
.国旗{
边框:1px实心#ccc;
填充物:5px;
位置:相对位置;
}
.flag img{
显示:块;
宽度:100%;
高度:自动;
}
.生物数据{
位置:绝对位置;
底部:5px;
左:5px;
右:0;
溢出:隐藏;
颜色:白色;
宽度:计算(100%-10px);
身高:0;
过渡:放松;
显示:块;
背景:rgba(0,0,0,0.5);
}
.flag:hover.biodata{
高度:计算(100%-10px);
}

他的名字是INASGOC的总裁

.biodata{height:100%}不是0如果你摆好小提琴,那会有帮助。这样一来,任何有时间帮忙的人,都必须投入更少的时间来研究这个问题:)我希望覆盖层在图像上,它仍然在填充上。有什么建议吗?
 <!DOCTYPE html>
    <html>
      <head>
        <style>
        .container {
          position: relative;
          width: 50%;
        }
        .image {
          display: block;
          width: 100%;
          height: auto;
        }
        .overlay {
          position: absolute;
          bottom: 100%;
          left: 0;
          right: 0;
          background-color: #008CBA;
          overflow: hidden;
          width: 100%;
          height:0;
          transition: .5s ease;

        }
        .container:hover .overlay {
          bottom: 0;
          height: 100%;

        }

        .text {

          white-space: nowrap; 
          color: white;
          font-size: 20px;
          position: absolute;
          overflow: hidden;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          -ms-transform: translate(-50%, -50%);

        }
        </style>
      </head>
      <body>
        <div class="container">
      <img src="https://upload.wikimedia.org/wikipedia/commons/8/83/Shaki_Waterfall2.jpg" alt="Avatar" class="image">
      <div class="overlay">
        <div class="text">
        <p style="padding:20px;">I am Mr. Alven</p>
      </div>
      </div>
    </div>
      </body>
    </html>