Html 将td显示的div居中

Html 将td显示的div居中,html,css,css-tables,Html,Css,Css Tables,我有一个表,是用div创建的,不是用创建的。我想我做得很好,但我想“colspan”两个div。我为你创造了一个新的世界 解决方案应无Javascript,请 我相信,放弃“表”的概念,只使用常规的HTML,可以更轻松地完成您想要完成的任务。试试这个: <style> label { display: inline-block; width: 200px; } </style> <form> <h2

我有一个表,是用div创建的,不是用
创建的。我想我做得很好,但我想“
colspan
”两个div。我为你创造了一个新的世界


解决方案应无Javascript,请

我相信,放弃“表”的概念,只使用常规的HTML,可以更轻松地完成您想要完成的任务。试试这个:

<style>
    label {
        display: inline-block;
        width: 200px;
    }
</style>
<form>
    <h2>Section heading here</h2>
    <div class="form-group">
        <label>Vorname:</label>
        <input type="text" name="vorname" placeholder="Max" required="required"/>
    </div>

    <h2>Hauptwohnsitz</h2>
    <div class="form-group">
        <label>Stra&szlig;e &amp; Hausnummer:</label>
        <input type="text" name="strasse0" placeholder="Musterstra&szlig;e 15" required="required"/>
    </div>
</form>

标签{
显示:内联块;
宽度:200px;
}
此处的章节标题
姓名:
第一户口
Straß;e&;豪斯努默:

您可以尝试为每行生成一个额外的单元格,并将
.tr\u占位符设置在其上方的绝对位置:

.tr_placeholder{
display:table-row;
vertical-align:middle;
text-align:center;
border-bottom:1px dotted #000000;
width:400px;
}
<style>
    label {
        display: inline-block;
        width: 200px;
    }
</style>
<form>
    <h2>Section heading here</h2>
    <div class="form-group">
        <label>Vorname:</label>
        <input type="text" name="vorname" placeholder="Max" required="required"/>
    </div>

    <h2>Hauptwohnsitz</h2>
    <div class="form-group">
        <label>Stra&szlig;e &amp; Hausnummer:</label>
        <input type="text" name="strasse0" placeholder="Musterstra&szlig;e 15" required="required"/>
    </div>
</form>
.table {
    display:table;
    border-collapse:collapse;
}
.tr {
    display:table-row;

}
.tr:before {
    display:table-cell;
    content:'';
    width:100px;
}
.td {
    display:table-cell;
    width:200px;
    vertical-align:middle;
}
.tr_placeholder {
    vertical-align:middle;
    text-align:center;
    width:100px;
    position:absolute;
    background:white;
        border-top:1px dotted #000000;
}
.tr_placeholder:before {
    display:none;
}