Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textarea inside div

Tags:

html

css

textarea

I think i'm doing something wrong here, I expect the textarea to be 10px smaller than the parent div on every side, but it's not like that, it's too small:

<html>
  <div style="position: absolute; left: 10px; top: 10px; width:50%; height: 50%; border: 1px solid #000000;">
    <textarea style="position: absolute; left: 10px; top: 10px; bottom: 10px; right: 10px; border: 1px solid #FF0000; resize:none;"></textarea>
  </div>
</html>

jsfiddle: http://jsfiddle.net/2a7LR/1/

why does this happen ? and how can i make it so it fits 10 px smaller in each side from the parent div ?

It appears correctly only in chrome/safari, but wrong in every other browser ( firefox, opera, IE8 )

like image 446
MirrorMirror Avatar asked May 25 '12 08:05

MirrorMirror


1 Answers

http://jsfiddle.net/2a7LR/5/ Adjusted some CSS for you. Basically used width: 100%; height: 100%, moved the 10px to the container's padding property, then added box-sizing to the textarea to make the size take the border into account.

like image 50
Niet the Dark Absol Avatar answered Sep 20 '22 06:09

Niet the Dark Absol