In the use of Div and CSS for Web page layout, Div's Adaptive height and adaptive width is a very common problem.
To ensure the overall beauty of the page, you need to keep the height/width of two or more layers consistent.
Right and left adaptive highly consistent Jquery
Copy Code code as follows:
<div style= "width:300px;" >
<div id= "left" style= "Float:left;background-color:blue;" >1<br/>3<br/>5<br/></div>
<div id= "Right" style= "float:right;background-color:red;" >2</div>
</div>
<script type= "Text/javascript" src= "Http://jt.875.cn/js/jquery.js" ></script>
<script type= "Text/javascript" >
$ (function () {
var heightleft= $ ("#Left"). Height ();
var heightright= $ ("#Right"). Height ();
if (Heightleft > Heightright)
{
$ ("#Right"). Height (heightleft);
}
Else
{
$ ("#Left"). Height (heightright);
}
})
</script>
div Height Adaptive Screen js
Copy Code code as follows:
<div id= "Top" style= "height=" 200px; ></div>
<div id= "box" >dsafsafsafsafsafdsa</div>
<script>
window.onload= function () {
function auto_height ()
{
//var h= document.documentelement.clientheight-200;
//var high = document.getElementById ("box");
//high.style.height=h+ "px";
document.getElementById ("box"). style.height=document.documentelement.clientheight-200+ "px";
}
Auto_height ();
Onresize=auto_height;
}
</script>