代码之家  ›  专栏  ›  技术社区  ›  Vignesh Kumar A

文本未正确消失

  •  1
  • Vignesh Kumar A  · 技术社区  · 12 年前

    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. 当我将鼠标悬停在图像上时,适当的文本将出现在图像的中心,也需要消失在图像本身的中心
    1 回复  |  直到 12 年前
        1
  •  3
  •   Community Mohan Dere    6 年前

    Updated Fiddle

    关键部分是移动

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

    发件人:

    #articlebottom .imgWrap:hover .imgDescription1

    收件人:

    #articlebottom .imgDescription1

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