css - % height without the height of the parent -


  • is possible give % height div without knowing height of parent? or better say, if height of parent changes. if not possible:

  • what better way have text , background of color , flexible device? text should have distance background. case:

here example simplified:http://jsfiddle.net/hqtmu/

html:

<div class="grey"> <div class="text"> lorem ipsum dolor sit amet, consectetur adipiscing elit. etiam magna erat, viverra @ elementum at, elementum vitae mauris. aenean in quam lorem, ut blandit ante. integer sit amet nisi massa, @ adipiscing nunc. duis in risus sapien blandit ultrices. morbi ut ante eu neque porta lacinia et sed nisi. donec luctus, enim in hendrerit ornare, purus libero adipiscing tortor, eget volutpat nunc tellus vitae turpis. mauris sed fringilla nibh. mauris pellentesque mauris eget velit iaculis tincidunt. suspendisse neque velit, adipiscing nec consectetur sit amet, porttitor sed tortor. vestibulum interdum auctor lorem, porta metus eleifend in. maecenas lobortis neque. duis fermentum arcu purus. praesent eget diam sed felis varius semper ut tortor. cras bibendum sollicitudin facilisis. pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. ut auctor adipiscing risus, eget interdum libero ultricies at. </div><!-- end text --> </div><!-- end grey --> 

css:

html, body { height: 100%; width: 100%; margin: 0; }  .grey{     position:relative;     margin:0px auto;     top:0px; left:0px;     width:90%;      height:auto;     min-width:320px;     background:grey;         }  .text {     position:relative;     margin:0px auto;     width:80%;      height:80%; /* no work ? */ } 

is trying achieve?

i used padding instead of heights.

http://jsfiddle.net/wsact/

.text {     position:relative;     margin:0px auto;     padding:10%; } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -