2013-04-23 237 views
0

我目前正在尝试使用CSS定位textarea并使其看起来不错。但它不起作用。使用css定位HTML textarea

相关CSS:

#BoardInput { 
padding:0px; 
width:100%; 
height:100%; 
} 
#BoardSmiley { 
min-width:100px; 
width:20%; 
padding:10px; 
border-right:thin solid #4E6011; 
border-bottom:thin solid #4E6011; 
background-color:#C6E466; 
} 
#BoardCode { 
border:thin solid #4E6011; 
background-color:#C6E466; 
padding:3px; 
} 

相关HTML:

<div id="BoardCode"> 
    <button onclick="addBBCode('[FETT]','[/FETT]');">Fett</button> 
    <button onclick="addBBCode('[KURSIV]','[/KURSIV]');">Kursiv</button> 
    <button onclick="addBBCode('[UNTERSTRICHEN]','[/UNTERSTRICHEN]');">Unterstrichen</button> 
    <button onclick="addLink();">Link</button> 
    <button onclick="addImage();">Bild</button> 
</div> 
<form action="index.php?s=board&action=addedit&where=<?=$Result['Overview']['PostID']?>" method="POST"> 
<table id="Board"> 
    <tr> 
     <td> 
       <textarea id="BoardInput" name="Text"></textarea> 
      <input type="hidden" name="ThreadID" value="<?=$Result['Overview']['ThreadID']?>" /> 
     </td> 
     <td id="BoardSmiley"> 
     <?php 
     $BoardTemplate->showSmileys(); 
     ?> 
     </td> 
    </tr> 
    <tr colspan="2"> 
     <td><input type="submit" value="OK" /> 
    </tr> 
</table> 
</form> 

的问题是,我想“代码”框上方的表情盒右侧和textarea的在左边。我希望他们能够完全相互调整。然而,textarea比上面的代码框右边多了1px,比右边的Smileys-Box多了2px。

我在这里做错了什么?

编辑:

的jsfiddle:jsfiddle.net/SSxSN和图像:

enter image description here

+1

这是_really_表格数据? – Kyle 2013-04-23 13:23:21

+1

您有使用表格的原因吗? – Michael 2013-04-23 13:24:24

+0

请提供[jsFiddle](http://jsfiddle.net) – Adrift 2013-04-23 13:26:45

回答

0

添加左侧和下切缘阴性,像这样:

#BoardInput { 
    padding:0px; 
    width:100%; 
    height:100%; 
    margin: 0 0 -8px -1px; 
} 

http://jsfiddle.net/SSxSN/1/

+0

问题是:为什么这需要?为什么不用普通的填充工作:0? – Shiuyin 2013-04-23 13:48:30

+0

,因为填充仅影响对象边框内的空间,而边距影响对象边框外的空间... – darwin 2013-04-23 14:13:14