Akshay
Akshay

Reputation: 14348

how to maintain position of text during height transition?

I want to maintain the position of the text but when hovered on the div, the text goes down

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;
}

Upvotes: 1

Views: 56

Answers (2)

Deepu Sasidharan
Deepu Sasidharan

Reputation: 5309

Add this..

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

DEMO

Upvotes: 1

codingrose
codingrose

Reputation: 15699

Add following to your css:

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

See DEMO here.

Upvotes: 2

Related Questions