如何在高度过渡期间保持文本的位置?

时间:2014-09-01 09:28:07

标签: html css

我想保持文本的位置但是当在div上盘旋时,文本会停止

HTML

<!DOCTYPE html>
<html>
<head>
<link href="site.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
<body>
<div></div>
<p>hover over the div element above, and the text goes down</p>
</body>
</html>

CSS

div {
width: 100px;
height: 100px;
background: red;
-webkit-transition: height 1s; 
}

div:hover {
height: 300px;
}

2 个答案:

答案 0 :(得分:2)

将以下内容添加到您的css:

p {
    position:absolute;
    top:100px;
}

See DEMO here

答案 1 :(得分:1)

添加此..

p
 {
    position: fixed;
    top: 125px;
 }

DEMO