0

当我将鼠标悬停在 div“post-wrap”中时,我想显示一个隐藏的 div“删除按钮”(#post-wrap)。我怎样才能用 CSS 做到这一点?

这是我到目前为止所做的:http: //jsfiddle.net/ksvrY/2/

#delete-button{
position: absolute;
right: 10px;
top: 10px;
margin: 0px 0px 0px 0px;
height: 30px;
width: 225px;
overflow: auto;
}
4

5 回答 5

0

见:http: //jsfiddle.net/ksvrY/4/

   #post-wrap:hover #delete-button{
        display:inherit;
    }

还隐藏按钮:

#delete-button{
        display:none;
    }
于 2013-01-24T22:18:29.570 回答
0

这将起作用:

#post-wrap:hover #delete-button { 
     display:block;    
}

#delete-button { display:none; }

...并且如果您想很好地使用它(根据需要附加必要的供应商前缀):

#post-wrap:hover #delete-button { 
     opacity:1;    
}

#delete-button { -webkit-transition:all 1s ease-in; opacity:0; }
于 2013-01-24T22:19:07.490 回答
0
#button-delete {display: none;}
#post-wrap:hover #button-delete {display: block;}

http://jsfiddle.net/ksvrY/5/

于 2013-01-24T22:19:38.377 回答
0

及其现在的工作:)

html

<div id="post-wrap">
    <div id="delete-button">
        <button id="button-delete"><p> Remove </p></button>
    </div>
</div>

CSS

#post-wrap {
    position: relative;
    margin: 20px 0px 0px 20px;
    padding: 10px 10px 10px 10px;
    height: auto;
    min-height: 150px;
    width: 200px;
    border: 1px solid #ddd;
    border-radius: 4px 4px 4px 4px;
    background-color: #fff;
/*  box-shadow: rgba(0, 0, 0, 0.247059) 0px 3px 8px 0px; */
    -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 3px 0px
}

#delete-button{
    position: absolute;
    right: 10px;
    top: 10px;
    margin: 0px 0px 0px 0px;
    height: 30px;
    width: 225px;
    overflow: auto;
}

#button-delete {
    cursor: pointer;
    float: right;
    height: 30px;
    width: auto;
    border: 1px solid #bbb;
    border-radius: 4px 4px 4px 4px;
    background-color: #eee;
    background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 3px 0px;
    display:none;
}

#button-delete p {
    margin: 0px 0px 0px 0px;
    padding: 0px 0px 0px 0px;
    font-family: calibri;
    font-weight: bold;
    font-size: 16px;
    color: #444;
}

#post-wrap:hover #button-delete{
    display:block;
}
于 2013-01-24T22:21:24.137 回答
0

使用悬停

http://jsfiddle.net/Ptxfy/

#post-wrap:hover #delete-button { 
     display:block;    
}

#delete-button { display:none; }

我不会使用直接子选择器,因为它不是必需的,并且可能会导致问题。

于 2013-01-24T22:21:41.990 回答