表内的CSS边距

Rag*_*azs 5 css margin

我正在尝试没有运气在表格中应用正确的边距

<html>
  <style>
    input,select {
      width: 100%;
      margin-right: 15px;
      background: red;
    }
  </style>
  <body>
    <table border="2" color="red" width="100%">
       <tr>
         <td width="25%"><input type="text" /></td>
         <td width="25%"><select><option>foobar</option></select></td>
         <td width="25%"><input type="text" /></td>
         <td width="25%"><input type="text" /></td>
       </tr>
       <tr>
         <td width="25%"><input type="text" /></td>
         <td width="25%"><input type="text" /></td>
         <td width="25%"><select><option>foobar</option></select></td>
         <td width="25%"><input type="text" /></td>
       </tr>
    <table>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

示例: http ://jsfiddle.net/3reat/

只使用CSS,可以定义这个边距100% - 15px?

@编辑

解决了宽度:calc(100% - 15px)来自@TamilSelvan的CSS3回复,带有空格

http://jsfiddle.net/3reat/2/

Tam*_*n C 3

尝试 css3 计算

(例如)

margin: calc(100% - 15px);
margin: -webkit-calc(100% - 15px);
margin: -moz-calc(100% - 15px);
Run Code Online (Sandbox Code Playgroud)

参考: https: //developer.mozilla.org/en-US/docs/CSS/calc