Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make input fields look like table cells in bootstrap 3

Tags:

I have a table in bootstrap 3

<table class="table table-bordered table-condensed">
    <tbody>
        <tr>
           <td><input type="text" class="form-control" /></td>
           <td><input type="text" class="form-control" /></td>
           <td><input type="text" class="form-control" /></td>
           <td><input type="text" class="form-control" /></td>
           <td><input type="text" class="form-control" /></td>
           <td><input type="text" class="form-control" /></td>
        </tr>
    </tbody>
</table>

Can I make the input fields look like normal cells? I want the input fields to fill out the entire cells (without no input margin nor table cell padding). Just like an Excel spreadsheet where I have many cells and can write in each of them.

like image 311
Jamgreen Avatar asked Sep 02 '14 15:09

Jamgreen


2 Answers

Yup. Do it this way:

input {display: block; padding: 0; margin: 0; border: 0; width: 100%;}
td {margin: 0; padding: 0;}

Fiddle: http://jsbin.com/biqomurafage/1

like image 182
Praveen Kumar Purushothaman Avatar answered Oct 12 '22 00:10

Praveen Kumar Purushothaman


You could also try using contentEditable tables like this: DEMO

<table>
    <tbody>
        <tr>
            <th></th>
            <th>A</th>
            <th>B</th>
            <th>C</th>
        </tr>
        <tr>
            <th>1</th>
            <td><span id="A1" contenteditable>#####</span></td>
            <td><span id="B1" contenteditable></span></td>
            <td><span id="C1" contenteditable></span></td>
        </tr>
        <tr>
            <th>2</th>
            <td><span id="A2" contenteditable></span></td>
            <td><span id="B2" contenteditable></span></td>
            <td><span id="C2" contenteditable></span></td>
        </tr>
    </tbody>
</table>

span {
    width: 100%;
    display: block;
}

*note, the content editable spans are required for IE to handle the contentEditable attributes correctly. Reference

like image 40
JRulle Avatar answered Oct 12 '22 01:10

JRulle