表内的CSS边距

前端之家收集整理的这篇文章主要介绍了表内的CSS边距前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试没有运气在表格中应用正确的边距
<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>

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

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

@编辑

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

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

解决方法

尝试css3 calc

(例如)

margin: calc(100% - 15px);
margin: -webkit-calc(100% - 15px);
margin: -moz-calc(100% - 15px);

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

猜你在找的CSS相关文章