HTML-按钮元素在表格元素之前,文本之前

时间:2019-02-11 01:56:30

标签: html element block display

我仍在学习HTML,以下代码段并未按预期显示。在不更改body元素的情况下,如何使元素以以下块方式显示...

Punnett广场:

单杂交杂交

button id =“ punnett_mono”

双杂交交叉

表5x5

button id =“ punnett_di”

代码段:

    <html>
    <body>
    <p><b>Punnett square:</b></p>
    <u>Monohybrid cross</u>
    <p>
    <table style="width: 50%; border-collapse: collapse; font-size: 25;">
    <tr>
    <td style="border: none; padding:30;"></td>
    <th colspan="2" style="border: 1 solid black; padding: 30;">Paternal:<br><div id="p_box" contenteditable></div></th>
    </tr>
    <tr>
    <th rowspan="2" style="border: 1 solid black;">Maternal:<br><div id="m_box" contenteditable></div></th>
    <td id="r2_c2" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="r2_c3" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <tr>
    <td id="r3_c2" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="r3_c3" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <input type="button" id="punnett_mono" onclick="p_mono p_box.innertext, m_box.innertext" value="Predict"/>
    </p>
    
    <u>Dihybrid cross</u>
    <p>
    <table style="width: 50%; border-collapse: collapse; font-size: 25;">
    <tr>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <tr>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <tr>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <tr>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <tr>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    <td id="" style="border: 1 solid black; padding: 30;">F1</td>
    </tr>
    <input type="button" id="punnett_di" onclick="p_di" value="Predict"/>
    </p>
    </body>
    </html>

2 个答案:

答案 0 :(得分:1)

在表结尾处使用</table>

答案 1 :(得分:0)

<html>

<body>
    <p><b>Punnett square:</b></p>
    <u>Monohybrid cross</u>
    <p>
        <table style="width: 50%; border-collapse: collapse; font-size: 25;">
            <tr>
                <td style="border: none; padding:30;"></td>
                <th colspan="2" style="border: 1 solid black; padding: 30;">
                    Paternal:<br>
                    <div id="p_box" contenteditable></div>
                </th>
            </tr>
            <tr>
                <th rowspan="2" style="border: 1 solid black;">
                    Maternal:<br>
                    <div id="m_box" contenteditable></div>
                </th>
                <td id="r2_c2" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="r2_c3" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
            <tr>
                <td id="r3_c2" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="r3_c3" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
        </table>
        <input type="button" id="punnett_mono" onclick="p_mono p_box.innertext, m_box.innertext" value="Predict" />
    </p>
    <u>Dihybrid cross</u>
    <p>

        <table style="width: 50%; border-collapse: collapse; font-size: 25;">
            <tr>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
            <tr>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
            <tr>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
            <tr>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
            <tr>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
                <td id="" style="border: 1 solid black; padding: 30;">F1</td>
            </tr>
         </table>
         <input type="button" id="punnett_di" onclick="p_di" value="Predict" />
    </p>
</body>

</html>

您必须关闭表格标签(: