鼠标悬停时,为什么P标签文本和边框高度增加不起作用?主要原因是什么?

的HTML:

<body>
    <div class="cheap">
        <p id= "pen">hello hannan .hello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannanhello hannan</p>

    </div>

</body>

CSS:

.cheap {
    width:500px;
    height: 500px;
    border: 1px solid rgb(25%,55%,45%);
    height: 10px;
}
 p{

 display: none;

}

.cheap:hover {
    width:400px;
    height:500px;

}

p:hover {
    display: block;
}


http://jsfiddle.net/najmul/JwKgG/

最佳答案

此CSS将起作用。在默认CSS中,您的P元素被display:none隐藏,因此您必须将鼠标悬停在.cheap类上

.cheap {
    width:500px;
    height: 500px;
    border: 1px solid rgb(25%,55%,45%);
    height: 10px;
}
.cheap p{
 display: none;
}

.cheap:hover {
    width:400px;
    height:500px;
}

.cheap:hover p {
    display: block;
}

关于html - P标签文字和边框高度悬停不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23570683/

10-11 13:49