图片将鼠标悬停时的文字显示为 "rollover"
Picture show text on hover as "rollover"
我想制作一个 "roll over text" 当你悬停图像容器时。
我做的很好,但只有绝对位置,但我不能用相对位置。
现在文本出现在图像之后,但我需要文本作为图像底部的小覆盖层
<div class="ce_image team block">
<figure class="image_container">
<img src="assets/images/c/De****-D1-6a7e730c.jpg" width="300" height="300" alt="">
<figcaption class="caption" style="width:300px">The text i want to display on hover</figcaption>
</figure>
</div>
css: (ps: 我想我的css真的很糟糕,从来没有做过这样的事情)
.image_container {
position: relative;
display: inline-block;
padding: 0.75em;
border: 1px solid #b2b9c4;
border-radius: 2px;
background: #ffffff;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.team .image_container figcaption, .team .image_container .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
display: none !important;
display: fixed;
color: #000000;
font-weight: bold;
position: static !important;
text-align: center;
top: 100px;
z-index: 999;
opacity: 0;
transition: opacity 0.2s linear !important;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: relative;
}
.team .image_container:hover figcaption, .team .image_container:hover .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
color: #000000;
font-weight: bold;
text-align: center;
top: -31px;
z-index: 999;
opacity: 1;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: relative;
display: block !important;
}
Fiddle 此处 css:
我更新了您的一些 CSS 以便文本位于底部。您需要绝对位置而不是相对位置:
.image_container {
position: relative;
display: inline-block;
padding: 0.75em;
border: 1px solid #b2b9c4;
border-radius: 2px;
background: #ffffff;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.team .image_container figcaption, .team .image_container .caption {
display: none !important;
}
.team .image_container:hover figcaption, .team .image_container:hover .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
color: #000000;
font-weight: bold;
text-align: center;
bottom: 0px;
z-index: 999;
opacity: 1;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: absolute;
display: block !important;
}
额外
如果您希望它适用于手机和平板电脑,请使用媒体查询:
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
我想制作一个 "roll over text" 当你悬停图像容器时。
我做的很好,但只有绝对位置,但我不能用相对位置。
现在文本出现在图像之后,但我需要文本作为图像底部的小覆盖层
<div class="ce_image team block">
<figure class="image_container">
<img src="assets/images/c/De****-D1-6a7e730c.jpg" width="300" height="300" alt="">
<figcaption class="caption" style="width:300px">The text i want to display on hover</figcaption>
</figure>
</div>
css: (ps: 我想我的css真的很糟糕,从来没有做过这样的事情)
.image_container {
position: relative;
display: inline-block;
padding: 0.75em;
border: 1px solid #b2b9c4;
border-radius: 2px;
background: #ffffff;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.team .image_container figcaption, .team .image_container .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
display: none !important;
display: fixed;
color: #000000;
font-weight: bold;
position: static !important;
text-align: center;
top: 100px;
z-index: 999;
opacity: 0;
transition: opacity 0.2s linear !important;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: relative;
}
.team .image_container:hover figcaption, .team .image_container:hover .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
color: #000000;
font-weight: bold;
text-align: center;
top: -31px;
z-index: 999;
opacity: 1;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: relative;
display: block !important;
}
Fiddle 此处 css:
我更新了您的一些 CSS 以便文本位于底部。您需要绝对位置而不是相对位置:
.image_container {
position: relative;
display: inline-block;
padding: 0.75em;
border: 1px solid #b2b9c4;
border-radius: 2px;
background: #ffffff;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.team .image_container figcaption, .team .image_container .caption {
display: none !important;
}
.team .image_container:hover figcaption, .team .image_container:hover .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
color: #000000;
font-weight: bold;
text-align: center;
bottom: 0px;
z-index: 999;
opacity: 1;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: absolute;
display: block !important;
}
额外
如果您希望它适用于手机和平板电脑,请使用媒体查询: http://www.w3schools.com/cssref/css3_pr_mediaquery.asp