简体   繁体   English

当悬停已经悬停以进行变换的图片时,如何显示文本?

[英]How can I make text appear when hovering a picture that has already the hovering for transform?

HTML HTML

<div class="feature" >
<img src="0308_WVenvirophotos1-water-pollutions.jpg" 
width="100%" height="100%"/></div>

CSS CSS

.feature{

height:50%;
width: 60%;
float: left;
margin: 0.5%;
-webkit-transition: width 1s, height 1s, -webkit-transform 2s; 
transition: width 1s, height 1s, transform 2s; 
}

.feature:hover{

width: 800px;
height: 520px;
-webkit-transform: translate(,) ; 
transform: translate(,);
}

This code makes the picture larger when hovered. 此代码使图片在悬停时变大。 How can I make the text appear on hover as well? 如何在悬停时显示文字?

Using the pseudo element :before , you can do something like this: 使用伪元素:之前 ,你可以这样做:

.feature:hover:before {
  content:'Text Goes Here';
  font-size:20px;
  color:white;
  position:absolute;
  top:0;
  left:0;    
}

Essentially, we're adding the text to the element on hover by using the content property of :before . 基本上,我们通过使用:之前的content属性在悬停时将文本添加到元素。

Checkout a fiddle showing that here: http://jsfiddle.net/34p5xqmL/ 看看这里显示的小提琴: http//jsfiddle.net/34p5xqmL/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 悬停时如何使文本显示在图像顶部? - How to make text appear on top of the image when hovering? 仅当将鼠标悬停在文本上时,如何显示收费提示? - How to make a tolltip appear only when hovering over text? 如何使我的引导程序轮播仅在悬停在一段文本上时出现? - How do I make my bootstrap carousel appear only when hovering over a piece of text? 悬停时如何显示新图像? - How to make a new image appear when hovering? 悬停菜单时如何显示描述? - how to make a description appear when hovering the menu? 将鼠标悬停在SVG路径上时如何显示div? - How can I make a div appear when hovering over a SVG path? 我如何使文本消失并通过将鼠标悬停在另一个文本上来使其他文本出现 - how do I make a text disappear and make different text appear by hovering over another text 将鼠标悬停在 tex 上并按下鼠标按钮时,如何使文本不可见? - How can I make the text invisible when hovering over a tex and pressing the mouse button? 当光标悬停在图片上方时如何使图片旋转 - how to make a picture spin when the cursur is hovering above it 将鼠标悬停在锚标签内的图像上且锚标签位于div内时,如何使文本显示? - How to make text appear when hovering over an image that's inside an anchor tag and the anchor tag is inside a div?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM