【问题标题】:How to get a text on a picture if the mouse is on it?如果鼠标在图片上,如何在图片上获取文字?
【发布时间】:2015-04-11 18:37:42
【问题描述】:

当我的鼠标在图像上时,我希望我的图片变得模糊,上面有文字,我已经把它弄模糊了,现在我想在图片变得模糊的时候在图像上显示文字。这就是我现在所拥有的,但现在我不知道在上面获取文字。我对此有点陌生,所以现在可能它太先进了,但也许你们可以帮助我。

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>

【问题讨论】:

  • 什么文字?在哪里?来吧,你可以在提问时做得更好!
  • 这里没有找到类似.blur的类发布相关代码!!

标签: html css image blur effect


【解决方案1】:

考虑一下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;
}

【讨论】:

    【解决方案2】:

    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;
    }
    

    Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-18
      • 1970-01-01
      • 2015-04-23
      • 1970-01-01
      • 2013-12-04
      • 2010-10-25
      • 1970-01-01
      • 2023-02-01
      相关资源
      最近更新 更多