So, here's a quick example which does what you want:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Repositioning example</title>
<style type="text/css">
body{
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
}
h1, p{
margin-top: 0;
padding-right: 15px;
padding-left: 15px;
}
#container{
width: 960px;
background: #FFF;
margin: 0 auto;
overflow: hidden;
}
#sidebar{
float: left;
width: 200px;
background: #EADCAE;
padding-top: 15px;
padding-bottom: 10px;
}
#content{
padding: 10px 0;
width: 760px;
float: left;
}
#red{
width:100%;
height:50px;
background:red;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="sidebar">
<p>
This is the sidebar.<br />
The red div will get pushed over here when the content in the main div exceeds a height of 500px
</p>
</div>
<div id="content">
<h1>Home</h1>
<p>This is your main page with a bit of text on it.</p>
<div id="red">This is a lovely red div. Isn't it tasteful?</div>
</div>
</div>
<script>
$(document).ready(function(){
var h = $("#content").height();
alert("The current height of the content div is " + h + "px");
if (h > 500){
$("#sidebar").append($("#red"));
}
});
</script>
</body>
</html>
As you will see, there is a div#red which is initially placed within div#content.
If the height of div#content grows to more than 500px, div#red is repositioned to div#sidebar.
You can alter the height by pasting the following into div#content a few times: <p> </p>
Does that help?
Bookmarks