文本域(含边框)的宽度100%显示实例页面
回到相关文章 »代码:
CSS代码:
/*仅border是固定数值*/ .box { padding: 40px 0 40px 6px; background-color: #34538b;} .box textarea { width: 99%; height: 80px; padding: 2px 0.5%; margin-left: -6px; border: 3px solid #cd0000; overflow: auto; } .box textarea:-moz-read-write { width: calc(100% - 6px); padding: 2px 3px; } /* border, padding一起固定数值 */ .box2 { padding: 40px 0 40px 12px; background-color: #34538b; } .box2 textarea { width: 100%; height: 80px; padding: 2px 3px; margin-left: -12px; border: 3px solid #cd0000; overflow: auto; }
HTML代码:
<div class="box"><textarea></textarea></div> <div class="box2"><textarea></textarea></div>
效果:
仅border是固定数值:
border, padding一起固定数值: