1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>HTML 4.01 </title>
<style type='text/css'>
#parent {height : 80%; position : absolute; top :10%; left : 10%; width:80%; border : 1px solid red;
white-space:nowrap;/* pour garder nos element aligner sur une seule ligne */ }
#parent #etai , #parent #enfant {display:inline-block;vertical-align:middle; /* modification du comportement d'affichage pour les centré verticalement es uns par rapports aux autres */}
#etai {width:0px;overflow:hidden;height:100%;padding:0;}
#enfant {
width:100%;
margin:0 -1px ;
white-space:normal;
border : 1px solid green;
/*
peut-etre veut t-on voir la barre de defilement apparaitre sur l'enfant plutot que le parent , pour eviter la barre de defilement horizontal
// max-height est incompatible IE 6
*/
max-height:100%;
overflow:auto;
}
p {margin:0;padding:3px;background:#eee;}
</style>
<!--[if lte ie 7]>
<style>
#parent #etai , #parent #enfant {display:inline;zoom:1;margin:0 -1px; /* rattrape les bordures de demo */ }
</style>
<![endif]-->
<script type="text/javascript" >
testh ='auto';
function hauteur () {
if (testh =='auto' ) {
testh='600px'}
else
{testh = 'auto' }
return testh;
}
</script>
</head>
<body>
<div id="parent">
<div id="enfant">
<p onclick =" this.style.height=hauteur();" > Un bloc positionné au milieu de son parent , quelque soit ,en theorie ,sa position ou comportement dans le flux , compatible IE lte 7 <br>
(clique moi pour changer ma hauteur <em> auto:600px </em>).</p>
</div>
<div id="etai"></div>
</div>
</body></html> |
Partager