如果鼠标在图片上,如何在图片上获取文字?
How to get a text on a picture if the mouse is on it?
我希望当我的鼠标在图像上时,我的图片上的文字变得模糊,我已经模糊了,现在我想在图片变得模糊的时候在图像上显示文字。这就是我现在所拥有的,但现在我不知道要在上面获取文本。我对此有点陌生,所以现在可能太高级了,但也许你们可以帮助我。
css:
.blur img {
transition: all 1s ease;
}
.blur img:hover {
-webkit-filter: blur(5px);
}
html:
<div class="blur">
<img src="picture.png" alt="picture">
<h1>Welcome!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aliquam ac varius arcu, sed luctus neque.
Nam varius sem vel nisi condimentum congue.
</div>
考虑这个DEMO
我用过这个css:
.blur img {
transition: all 1s ease;
}
.blur img:hover {
-webkit-filter: blur(5px);
}
.blur:hover .inner{
opacity:1;
}
.blur{
position:relative;
width:100px;
}
.blur span{
position:absolute;
top: 100px;
left: 50px;
font-size:24px;
opacity:0;
}
HTML:
<ul class="img-list">
<li>
<a href="http://nataliemac.com">
<img src="http://geekgirllife.com/images/filename.jpg" width="150" height="150" />
<span class="text-content"><span>Place Name</span></span>
</a>
</li>
...
</ul>
CSS:
ul.img-list {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
ul.img-list li {
display: inline-block;
height: 150px;
margin: 0 1em 1em 0;
position: relative;
width: 150px;
}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 150px;
left: 0;
position: absolute;
top: 0;
width: 150px;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
ul.img-list li:hover span.text-content {
opacity: 1;
}
我希望当我的鼠标在图像上时,我的图片上的文字变得模糊,我已经模糊了,现在我想在图片变得模糊的时候在图像上显示文字。这就是我现在所拥有的,但现在我不知道要在上面获取文本。我对此有点陌生,所以现在可能太高级了,但也许你们可以帮助我。
css:
.blur img {
transition: all 1s ease;
}
.blur img:hover {
-webkit-filter: blur(5px);
}
html:
<div class="blur">
<img src="picture.png" alt="picture">
<h1>Welcome!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aliquam ac varius arcu, sed luctus neque.
Nam varius sem vel nisi condimentum congue.
</div>
考虑这个DEMO
我用过这个css:
.blur img {
transition: all 1s ease;
}
.blur img:hover {
-webkit-filter: blur(5px);
}
.blur:hover .inner{
opacity:1;
}
.blur{
position:relative;
width:100px;
}
.blur span{
position:absolute;
top: 100px;
left: 50px;
font-size:24px;
opacity:0;
}
HTML:
<ul class="img-list">
<li>
<a href="http://nataliemac.com">
<img src="http://geekgirllife.com/images/filename.jpg" width="150" height="150" />
<span class="text-content"><span>Place Name</span></span>
</a>
</li>
...
</ul>
CSS:
ul.img-list {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
ul.img-list li {
display: inline-block;
height: 150px;
margin: 0 1em 1em 0;
position: relative;
width: 150px;
}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 150px;
left: 0;
position: absolute;
top: 0;
width: 150px;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
ul.img-list li:hover span.text-content {
opacity: 1;
}