我想建立一个包含三列的HTML表。在这三列之一中,我想从中删除行。
我尝试使用rowspan
<table style="width:100%; margin-block-start: 5px;font-size:20px;border: 1px solid black;">
<tr>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Tasks</th>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Sales Performance</th>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Staffs' Annual Leave</th>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Yesterday</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">50</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Today</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">50</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Tomorrow</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Upcoming</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Some other day</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
</table>
和import MyClass from '../MyClass';
test('navigation using javascript', () => {
const url = "someurl";
const spy = jest.spyOn(MyClass, 'eval');
MyClass.hopJavascript(url);
expect(spy).toHaveBeenCalled();
});
之类的代码,但它们无济于事。
{{1}}
我的期望
现实
答案 0 :(得分:2)
尝试一下:
table {
border-collapse: collapse;
}
th, td {
margin: 0px;
padding: 15px;
border: 1px solid black;
}
td.no-data {
border: 0px;
}
<table style="width:100%; margin-block-start: 5px;font-size:20px;border: 1px solid black;">
<tr>
<th>Tasks</th>
<th>Sales Performance</th>
<th>Staffs' Annual Leave</th>
</tr>
<tr>
<td><i>Yesterday</i></td>
<td class="no-data"></td>
<td>50</td>
</tr>
<tr>
<td><i>Today</i></td>
<td class="no-data"></td>
<td>50</td>
</tr>
<tr>
<td><i>Tomorrow</i></td>
<td class="no-data"></td>
<td>94</td>
</tr>
<tr>
<td><i>Upcoming</i></td>
<td class="no-data"></td>
<td>94</td>
</tr>
<tr>
<td><i>Some other day</i></td>
<td class="no-data"></td>
<td>94</td>
</tr>
</table>
答案 1 :(得分:1)
尝试将inline-style
替换为class
或data-attribute
table {
width: 100%;
font-size: 20px;
border-collapse: collapse;
}
th {
padding: 15px;
text-align: left;
border: 1px solid black;
}
td {
padding: 15px;
border: 1px solid black;
}
.no-border {
border: 0;
}
<table style="width:100%; margin-block-start: 5px;font-size:20px;border: 1px solid black;">
<tr>
<th>Tasks</th>
<th>Sales Performance</th>
<th>Staffs' Annual Leave</th>
</tr>
<tr>
<td>
<i>Yesterday</i>
</td>
<td class=" no-border"></td>
<td>50</td>
</tr>
<tr>
<td>
<i>Today</i>
</td>
<td class="no-border"></td>
<td>50</td>
</tr>
<tr>
<td>
<i>Tomorrow</i>
</td>
<td class="no-border"></td>
<td>94</td>
</tr>
<tr>
<td>
<i>Upcoming</i>
</td>
<td class="no-border"></td>
<td>94</td>
</tr>
<tr>
<td>
<i>Some other day</i>
</td>
<td class="no-border"></td>
<td>94</td>
</tr>
</table>
答案 2 :(得分:1)
您需要向表中添加border-collapse
样式,并使用rowspan
属性来扩展您的第一个<td>
。
当您 rowspan 您的第一个<td>
时,您无需在以下<td>
中添加更多的<tr>
标签,因为前<td>
会一直扩展到rowspan
属性的值(要跨越的行数),例如rowspan=5
会扩展到当前表的末尾。
<table style="width:100%; margin-block-start: 5px;font-size:20px;border: 1px solid black; border-collapse:collapse">
<tr>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Tasks</th>
<th style="padding: 15px;text-align: left;border: 1px solid black;" >Sales Performance</th>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Staffs' Annual Leave</th>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Yesterday</i></td>
<td rowspan='5'</td>
<td style="padding: 15px;border: 1px solid black;">50</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Today</i></td>
<td style="padding: 15px;border: 1px solid black;">50</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Tomorrow</i></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Upcoming</i></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Some other day</i></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
</table>
答案 3 :(得分:1)
添加了几行代码后,它就可以实现我想要的东西:
Private sub Commandbuttonclick ()
If Me.ComboBox1.Value = "" Then
MsgBox "Request No. Can Not be Blank", vbExclamation, "Request No."
Exit Sub
End If
requestno = Me.ComboBox1.Value
Sheets("DASHBOARD").Select
Dim rowselect As Double
rowselect = Me.combobox1.Value
rowselect = rowselect + 1
Rows(rowselect).Select
Cells(rowselect, 2) = Me.TextBox1.Value
Cells(rowselect, 3) = Me.TextBox2.Value
Cells(rowselect, 4) = Me.TextBox3.Value
第一部分是从导航栏中放下表格。 第二部分是得到我期望的桌子。
谢谢您回答我的问题。
如果您想了解其余代码,请查看Sushil和Nawras的答案。
P.S。是的,我是所有这些的入门者。
答案 4 :(得分:0)
使用border-collapse: collapse;
作为表格标签。
<table style="width:100%; margin-block-start: 5px;font-size:20px;border: 1px solid black; border-collapse: collapse;">
<tr>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Tasks</th>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Sales Performance</th>
<th style="padding: 15px;text-align: left;border: 1px solid black;">Staffs' Annual Leave</th>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Yesterday</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">50</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Today</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">50</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Tomorrow</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Upcoming</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
<tr>
<td style="padding: 15px;border: 1px solid black;"><i>Some other day</i></td>
<td style="padding: 15px;border: 1px solid black;border-style: hidden;"></td>
<td style="padding: 15px;border: 1px solid black;">94</td>
</tr>
</table>
答案 5 :(得分:0)
您只需替换边框样式:隐藏;边界:无;
在该列中,您无需设置边框即可应用 style =“ border:none;”