【问题标题】:Text not disappearing properly文字没有正确消失
【发布时间】:2014-03-25 11:09:46
【问题描述】:

CSS

#articlebottom {
    width: 980px;
    height: 250px;          
}

.products{
    width:980px;
    margin:0px auto;
    padding-left:20px;
} 
#articlebottom .imgWrap {
    width:295px;
    height:200px;
    position:relative;
    float:left;
    margin:10px;
    background:#333;
}
#articlebottom .imgWrap img {
    position:absolute;
    left:5px;
    top:5px;
    width:285px;
    height:190px;
}

#articlebottom .imgDescription1 {
    position: absolute;
    left:0;
    letter-spacing: 2px;
    background-color: rgba(255, 250, 250, 0.2);
    color: rgba(255, 250, 250, 0.2);
    font-weight:bold;
    font-size:18pt;
    line-height: 50px;
    width:100%;
    height:50px;
    opacity: 0;
    text-align:center;
    text-transform:uppercase;
    transition:opacity 500ms ease-in-out, color 20ms ease-in-out,height 500ms ease-in-out;
}

#articlebottom .imgWrap:hover .imgDescription1 {
    opacity: 1;
    height:200px;
    line-height:200px;
    color: #1b9bff;
}

HTML

  <article id="articlebottom">
                <div class="products">

                    <div class="imgWrap">
                        <a href="Products/Camphor.aspx"  target="_blank"><img src="Images/Camphor_b.JPG" alt="polaroid" />
                        <p class="imgDescription1">Camphor</p></a>
                    </div>
                    </div>
</article>

Fiddle

我有什么:

  1. 当我悬停时文本显示在中心,悬停后进入顶部

我需要什么:

  1. 当我将鼠标悬停在图像上时,相应的文本应该出现在中心,并且还需要消失在图像本身的中心

【问题讨论】:

标签: html css


【解决方案1】:

Updated Fiddle

关键部分在移动

    height:200px;
    line-height:200px;
    color: #1b9bff;

发件人:

#articlebottom .imgWrap:hover .imgDescription1

收件人:

#articlebottom .imgDescription1

否则,文本的位置将设置为默认/继承值,并且仅设置为在悬停时居中,因此悬停状态会看到它跳跃。

【讨论】:

  • 这很好,但我需要透明需要上下
  • @VigneshKumar 如果“覆盖”滑入不是更好吗?目前,文本只是在“覆盖”到达之前淡入。看起来有点奇怪。
  • @VigneshKumar 像这样。 DEMO 或者这个DEMO 注意:他们的高度不正确,因为我只是快速完成了。
  • @SW4 太好了..如果我想自下而上意味着我应该怎么做
  • @Vignesh Kumar 我会针对您的后续要求发布一个单独的问题,以使其获得更多社区的关注并在未来更好地帮助其他用户
猜你喜欢
  • 2014-03-31
  • 1970-01-01
  • 2020-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-20
  • 2019-05-29
  • 2018-10-12
相关资源
最近更新 更多