Javascript 我想把桌子的标题系上我做不到
@进口urlhttps://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100; 身体{ 背景色:3e94ec; 字体系列:Roboto、helvetica、arial、无衬线字体; 字体大小:16px; 字体大小:400; 文本呈现:优化易读性; } 分区表格标题{ 显示:块; 保证金:自动; 最大宽度:600px; 填充物:5px; 宽度:100%; } .表格标题h3{ 颜色:fafafa; 字体大小:30px; 字体大小:400; 字体风格:普通; 字体系列:Roboto、helvetica、arial、无衬线字体; 文本阴影:-1px-1px 1px rgba0,0,0.1; 文本转换:大写; } /***表格样式**/ .表格填写{ 背景:白色; 边界半径:3px; 边界塌陷:塌陷; 高度:320px; 保证金:自动; 最大宽度:600px; 填充物:5px; 宽度:100%; 盒影:0 5px 10px rgba0,0,0,0.1; 动画:无限浮动; } th{ 颜色:D5DDE5; ; 背景:1b1e24; 边框底部:4px实心9ea7af; 右边框:1px实心343a45; 字体大小:23px; 字号:100; 填充:24px; 文本对齐:左对齐; 文本阴影:0 1px 1px rgba0,0,0,0.1; 垂直对齐:中间对齐; } 第一个孩子{ 边框左上半径:3px; } 最后一个孩子{ 边框右上角半径:3px; 边界权:无; } tr{ 边框顶部:1px实心C1C3D1; 边框底部-:1px实心C1C3D1; 颜色:666B85; 字体大小:16px; 字体大小:正常; 文本阴影:0 1px 1px rgba256、256、256、0.1; } tr:悬停td{ 背景:4E5066; 颜色:FFFFFF; 边框顶部:1px实心22262e; } tr:第一个孩子{ 边界顶部:无; } tr:最后一个孩子{ 边框底部:无; } tr:nth奇尔奇td{ 背景:EBEBEB; } tr:N儿童奇数:悬停td{ 背景:4E5066; } tr:最后一个孩子td:第一个孩子{ 边框左下半径:3px; } tr:最后一个孩子td:最后一个孩子{ 边框右下半径:3px; } 运输署{ 背景:FFFFFF; 填充:20px; 文本对齐:左对齐; 垂直对齐:中间对齐; 字体大小:300; 字号:18px; 文本阴影:-1px-1px 1px rgba0,0,0.1; 右边框:1px实心C1C3D1; } td:最后一个孩子{ 右边框:0px; } 文本左{ 文本对齐:左对齐; } 文本中心{ 文本对齐:居中; } 右文本{ 文本对齐:右对齐; } td.text-left{ 文本对齐:左对齐; } 文本中心{ 文本对齐:居中; } td.text-right{ 文本对齐:右对齐; } 标题{ 光标:指针; } 桌式 项目 卡路里 面包、蛋糕和饼干 黑面包和白面包 中号大面包 80 蛋糕的种类与emsp;中号片2盎司 200-350 饼干及emsp;普通饼干 甜饼干 60 80 铈 四月 $ 56,000.00 也许 $ 98,000.00 现场Gif: 演示: 代码:Javascript 我想把桌子的标题系上我做不到,javascript,html,css,bootstrap-4,html-table,Javascript,Html,Css,Bootstrap 4,Html Table,@进口urlhttps://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100; 身体{ 背景色:3e94ec; 字体系列:Roboto、helvetica、arial、无衬线字体; 字体大小:16px; 字体大小:400; 文本呈现:优化易读性; } 分区表格标题{ 显示:块; 保证金:自动; 最大宽度:600px; 填充物:5px; 宽度:100%; } .表格标题h3{ 颜色:fafafa; 字体大小:30px; 字体大小:
在哪件事之后崩溃?点击什么?悬停在什么东西上?我希望它是在点击感谢你的努力,但当我点击面包,蛋糕和饼干行应折叠,而不是整个身体。。和ceriels一样,它的行应该是折叠的,你能做到吗?是的,请参见上面的@shumayil。我为您更新了代码和演示。@shumayil更新了文章,添加了gif链接,以便您现在很容易看到它具有正确的功能
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100);
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
@import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100);
body {
background-color: #3e94ec;
font-family: "Roboto", helvetica, arial, sans-serif;
font-size: 16px;
font-weight: 400;
text-rendering: optimizeLegibility;
}
div.table-title {
display: block;
margin: auto;
max-width: 600px;
padding: 5px;
width: 100%;
}
.table-title h3 {
color: #fafafa;
font-size: 30px;
font-weight: 400;
font-style: normal;
font-family: "Roboto", helvetica, arial, sans-serif;
text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);
text-transform: uppercase;
}
/*** Table Styles **/
.table-fill {
background: white;
border-radius: 3px;
border-collapse: collapse;
height: 320px;
margin: auto;
max-width: 600px;
padding: 5px;
width: 100%;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
animation: float 5s infinite;
}
th {
color: #D5DDE5;
background: #1b1e24;
border-bottom: 4px solid #9ea7af;
border-right: 1px solid #343a45;
font-size: 23px;
font-weight: 100;
padding: 24px;
text-align: left;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
vertical-align: middle;
}
th:first-child {
border-top-left-radius: 3px;
}
th:last-child {
border-top-right-radius: 3px;
border-right: none;
}
tr {
border-top: 1px solid #C1C3D1;
border-bottom: 1px solid #C1C3D1;
color: #666B85;
font-size: 16px;
font-weight: normal;
text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);
}
tr:hover td {
background: #4E5066;
color: #FFFFFF;
border-top: 1px solid #22262e;
}
tr:first-child {
border-top: none;
}
tr:last-child {
border-bottom: none;
}
tr:nth-child(odd) td {
background: #EBEBEB;
}
tr:nth-child(odd):hover td {
background: #4E5066;
}
tr:last-child td:first-child {
border-bottom-left-radius: 3px;
}
tr:last-child td:last-child {
border-bottom-right-radius: 3px;
}
td {
background: #FFFFFF;
padding: 20px;
text-align: left;
vertical-align: middle;
font-weight: 300;
font-size: 18px;
text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);
border-right: 1px solid #C1C3D1;
}
td:last-child {
border-right: 0px;
}
th.text-left {
text-align: left;
}
th.text-center {
text-align: center;
}
th.text-right {
text-align: right;
}
td.text-left {
text-align: left;
}
td.text-center {
text-align: center;
}
td.text-right {
text-align: right;
}
tr.header {
cursor: pointer;
}
</style>
</head>
<body>
<div class="table-title">
</div>
<table class="table-fill table table-hover">
<thead>
<tr>
<th class="text-left">items</th>
<th class="text-left">calories</th>
</tr>
</thead>
</table>
<table class="table-fill table table-hover">
<thead>
<tr>
<th colspan="2">Bread,cakes and biscuits</th>
</tr>
</thead>
<tbody class="table-hover">
<tr>
<td class="text-left">brown bread and white<br>  medium size large loaf</td>
<td class="text-left"><br>80</td>
</tr>
<tr>
<td class="text-left">Cakes-very according to type <br>   medium slice 2 oz</td>
<td class="text-left"><br>200-350</td>
</tr>
<tr>
<td class="text-left">Biscuits <br>  plain biscuits <br>  sweet biscuits</td>
<td class="text-left"><br>60 <br>80</td>
</tr>
</tbody>
</table>
<table class="table-fill table table-hover">
<thead>
<tr class="header">
<th colspan="2">ceriels</th>
</tr>
</thead>
<tbody class="table-hover">
<tr>
<td class="text-left">April</td>
<td class="text-left">$ 56,000.00</td>
</tr>
<tr>
<td class="text-left">May</td>
<td class="text-left">$ 98,000.00</td>
</tr>
</tbody>
</table>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- Optional JavaScript -->
<script>
$("tr").find("th").on("click", function() {
$(this).closest("table").find("tbody").toggle(); //you can set delay within toggle as well, like .toggle(500);
});
</script>
</body>
</html>