【发布时间】:2012-05-25 08:46:31
【问题描述】:
我认为我在这里做错了,我希望 textarea 在每一侧都比父 div 小 10px,但事实并非如此,它太小了:
<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/
为什么会这样?我怎样才能使它适合从父 div 的每边小 10 像素?
它只在 chrome/safari 中正确显示,但在其他所有浏览器(firefox、opera、IE8)中都错误
【问题讨论】:
-
你需要正好 10px 还是你可以使用 % width/height 作为文本框?
-
即使使用百分比也不起作用:jsfiddle.net/2a7LR/6