我有一个由div
元素组成的表,该表的行是使用Jinja2变量从for循环生成的。问题是我需要将整个表行包含在form
元素中,但是这样做会破坏格式并破坏表行中的表头。如何在不破坏格式的情况下实现下面的目标?
所有行单元格都需要包含在循环表单中,因为我将这些单元格用作用户输入。
div.blueTable {
border: 1px solid #1C6EA4;
background-color: #EEEEEE;
width: 100%;
text-align: left;
border-collapse: collapse;
}
.divTable.blueTable .divTableCell, .divTable.blueTable .divTableHead {
border: 1px solid #AAAAAA;
padding: 3px 2px;
}
.divTable.blueTable .divTableBody .divTableCell {
font-size: 13px;
}
.divTable.blueTable .divTableRow:nth-child(even) {
background: #D0E4F5;
}
.divTable.blueTable .divTableHeading {
background: #1C6EA4;
background: -moz-linear-gradient(top, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
background: -webkit-linear-gradient(top, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
background: linear-gradient(to bottom, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
border-bottom: 2px solid #444444;
}
.divTable.blueTable .divTableHeading .divTableHead {
font-size: 15px;
font-weight: bold;
color: #FFFFFF;
border-left: 2px solid #D0E4F5;
}
.divTable.blueTable .divTableHeading .divTableHead:first-child {
border-left: none;
}
.blueTable .tableFootStyle {
font-size: 14px;
}
.blueTable .tableFootStyle .links {
text-align: right;
}
.blueTable .tableFootStyle .links a{
display: inline-block;
background: #1C6EA4;
color: #FFFFFF;
padding: 2px 8px;
border-radius: 5px;
}
.blueTable.outerTableFooter {
border-top: none;
}
.blueTable.outerTableFooter .tableFootStyle {
padding: 3px 5px;
}
/* DivTable.com */
.divTable{ display: table; }
.divTableRow { display: table-row; }
.divTableHeading { display: table-header-group;}
.divTableCell, .divTableHead { display: table-cell;}
.divTableHeading { display: table-header-group;}
.divTableFoot { display: table-footer-group;}
.divTableBody { display: table-row-group;}
<div class="divTable blueTable">
<div class="divTableHeading">
<div class="divTableRow">
<div class="divTableHead">head1</div>
<div class="divTableHead">head2</div>
<div class="divTableHead">head3</div>
</div>
</div>
<div class="divTableBody">
<form method="POST"> <!-- For loop starts here -->
<div class="divTableRow">
<input type="hidden" name="post_id" value="jinja variable used for id">
<div class="divTableCell"><input type="text" value="someValue"></div>
<div class="divTableCell"><input type="text" value="anotherValue"></div>
<div class="divTableCell"><button>Submit</button></div>
</div>
</form> <!-- For loop ends here -->
</div>
</div>
答案 0 :(得分:1)
您累了吗
<form method="post" class="divTableRow">
<input type="hidden" name="post_id" value="jinja variable used for id">
<div class="divTableCell"><input type="text" value="someValue"></div>
<div class="divTableCell"><input type="text" value="anotherValue"></div>
<div class="divTableCell"><button>Submit</button></div>
</form> <!-- For loop ends here -->