0

How do I change an element's position so that it adapts to the element above it, so when the box gets bigger (as people enter more text, the box's {height:auto;} gets bigger or smaller as more text gets entered) anyway how do I make the second box's position go just 5px (the space between the boxes) past the first box?

winner_joiner
  • 12,173
  • 4
  • 36
  • 61
BrendanMann_1
  • 11
  • 1
  • 1
  • 2
  • 2
    `margin-top:5px`? Can you be more specific? – Passerby Jul 12 '13 at 03:11
  • You can't do this with CSS alone. You need to use Javascript [http://stackoverflow.com/questions/454202/creating-a-textarea-with-auto-resize][1] [1]: http://stackoverflow.com/questions/454202/creating-a-textarea-with-auto-resize – Shang Jul 12 '13 at 03:12

1 Answers1

0

Do you have the ability to nest the elements? If so you could use relative positioning. Here is a fiddle, I made the top <div> resizable with jQuery UI so you can see the second <div> responding to the change in height of the first one: http://jsfiddle.net/RFaGZ/

HTML:

<body>
    <div id="one">
        <div id="two"></div>
    </div>
</body> 

CSS:

#one {
    height: 200px;
    width: 200px;
    border: 1px solid black;
}

#two {
    height: 100px;
    width: 200px;
    position: relative;
    top:103%;
    border: 1px solid black;
}
digiliooo
  • 821
  • 7
  • 9