`input`在表格中的位置

时间:2017-08-06 08:19:28

标签: html css

有人可以解释input类型&#34;提交&#34;虽然它位于第三个<tr>内,但它位于左上角 我可以通过marginposition属性将其位置更改为正确的位置,但在这种情况下根本不需要它们。 看到代码:

&#13;
&#13;
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Home</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div style="border:2px solid black;margin-top:10%;">
                <div class="row">
                    <table style="margin-left:10%;width:85%;" class="table table-hover">
                        <thead>
                            <tr>
                                <th>album name</th>
                                <th>Number of images</th>
                                <th>Order</th>
                            </tr>
                        </thead>

                        <tr>
                            <td>
                                <input placeholder="album's name" name="album_name">
                            </td>

                            <td>
                                <input placeholder="#of images eg.8" id="no_of_images" name="NoOfImages">
                            </td>

                            <td>
                                <input placeholder="order between other albums eg. 1" name="album_order">
                            </td>
                        </tr>

                        <tr>
                            <input  style="" class="btn btn-info btn-md" value="Submit" name="submit">

                        </tr>
                    </table>

                    <table style="margin-top:10%;" id="images_table" class="table table-hover">
                    </table>
                </div>
            </div>
        </div>
    </body>
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

像这样插入td

<td> <---------------
     <input  style="" class="btn btn-info btn-md" value="Submit" name="submit">
</td> <--------------

&#13;
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
    <div style="border:2px solid black;margin-top:10%;">
        <div class="row">
            <table style="margin-left:10%;width:85%;" class="table table-hover">
                <thead>
                    <tr>
                       <th>album name</th>
                       <th>Number of images</th>
                       <th>Order</th>
                    </tr>
                </thead>
                    <tr>
                        <td>
                           <input placeholder="album's name" name="album_name">
                        </td>

                        <td>
                            <input placeholder="#of images eg.8" id="no_of_images" name="NoOfImages">
                        </td>

                        <td>
                            <input placeholder="order between other albums eg. 1" name="album_order">
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <input  style="" class="btn btn-info btn-md" value="Submit" name="submit">
                        </td>
                    </tr>
            </table>
            <table style="margin-top:10%;" id="images_table" class="table table-hover">
            </table>
        </div>
    </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

你忘了在你的tr部分添加td,并且因为你的第三个tr只有一个td,你必须将colspan设置为3作为它的属性......

&#13;
&#13;
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Home</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div style="border:2px solid black;margin-top:10%;">
                <div class="row">
                    <table style="margin-left:10%;width:85%;" class="table table-hover">
                        <thead>
                            <tr>
                                <th>album name</th>
                                <th>Number of images</th>
                                <th>Order</th>
                            </tr>
                        </thead>

                        <tr>
                            <td>
                                <input placeholder="album's name" name="album_name">
                            </td>

                            <td>
                                <input placeholder="#of images eg.8" id="no_of_images" name="NoOfImages">
                            </td>

                            <td>
                                <input placeholder="order between other albums eg. 1" name="album_order">
                            </td>
                        </tr>

                        <tr>
                            <td colspan="3">
                                <input  style="" class="btn btn-info btn-md" value="Submit" name="submit">
                            </td>


                        </tr>
                    </table>

                    <table style="margin-top:10%;" id="images_table" class="table table-hover">
                    </table>
                </div>
            </div>
        </div>
    </body>
</html>
&#13;
&#13;
&#13;