0

so I'm using the following code to change the contents of a div: document.getElementById("boxed").innerHTML = document.getElementById("aboutus").innerHTML;

And the following is the CSS code behind the div "boxed":

.boxed
{
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    width: 90%;
    min-height: 90%;
    height:auto;
    top:50%;
    background-color:#F5F5F5;
}

How can I keep the div centered vertically while at the same time allowing for vertical resizing based on the content within? I don't want to use overflow; I want the div itself to change size when I click a button that executes the Javascript code.

Aneesh Ashutosh
  • 762
  • 7
  • 18
  • are you using jquery? – mrtig Feb 20 '14 at 20:33
  • 1
    Block elements automatically adjust their height to fit the content. If you have vertical centering you'll need a css method that accounts for changing sizes, or just re-calc the position using javascript – helion3 Feb 20 '14 at 20:34
  • This is a css question and this can be solved css only by using. Possible duplicate: http://stackoverflow.com/questions/14189625/true-center-vertical-and-horizontal-css-div – timing Feb 20 '14 at 20:35

0 Answers0