CSS fields inside a table

I try not to use the right margins inside tables

<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>

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

Only using CSS can you define these fields 100% - 15px?

@Edit

Resolved with width: calc(100% - 15px)CSS3 answer from @TamilSelvan with spaces

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

+5
source share
2 answers

try css3 calc

(eg)

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

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

+3
source

Aren't you just looking for a supplement?

padding : 15px;

It matches the field, but inside.

-1
source

All Articles