我想在引导程序中使用响应表,但是我的代码有问题,它可能无法正常工作。

这是我的代码:



table {
  width: 100%;
  border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
  background: #eee;
}
th {
  background: #333;
  color: white;
  font-weight: bold;
}
td, th {
  padding: 6px;
  border: 1px solid #ccc;
  text-align: left;
}
@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {

	/* Force table to not be like tables anymore */
	table, thead, tbody, th, td, tr {
		display: block;
	}

	/* Hide table headers (but not display: none;, for accessibility) */
	thead tr {
		position: absolute;
		top: -9999px;
		left: -9999px;
	}

	tr { border: 1px solid #ccc; }

	td {
		/* Behave  like a "row" */
		border: none;
		border-bottom: 1px solid #eee;
		position: relative;
		padding-left: 50%;
	}

	td:before {
		/* Now like a table header */
		position: absolute;
		/* Top/left values mimic padding */
		top: 6px;
		left: 6px;
		width: 45%;
		padding-right: 10px;
		white-space: nowrap;
	}

<table class="table table-responsive">
  <thead>
    <tr>
      <th>X Title</th>
      <th>Y Title</th>
      <th>Z Title</th>
    </tr>
  </thead>
  <tbody>
 <tr>
   <td> XXX </td>
   <td> YYY </td>
   <td> ZZZ </td>
 </tr>
</tbody>
   </table>





我不知道如何使它仅在移动设备或小屏幕尺寸下才能像下面的图像一样工作:

Mobile View

**


  在移动视图中,我要删除X TITLE,该怎么做?


**

提前致谢

最佳答案

Please follow the link

http://codepen.io/srees/pen/KNPPJy?editors=1100

Hope you got the answer




body {
  padding:1.5em;
  background: #f5f5f5;
}

table {
  border: 1px #a39485 solid;
  font-size: .9em;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
  width: 100%;
  border-collapse: collapse;
  border-radius: 5px;
  overflow: hidden;
}

th {
  text-align: left;
}

thead {
  font-weight: bold;
  color: #000;
  background: #d5d5d5;
}

 td, th {
  padding: 1em .5em;
  vertical-align: middle;
}

 td {
  border-bottom: 1px solid rgba(0,0,0,.1);
  background: #fff;
}

a {
  color: #73685d;
}

 @media all and (max-width: 768px) {

  table, thead, tbody, th, td, tr {
    display: block;
  }

  th {
    text-align: right;
  }

  table {
    position: relative;
    padding-bottom: 0;
    border: none;
    box-shadow: 0 0 10px rgba(0,0,0,.2);
  }

  thead {
    float: left;
    white-space: nowrap;
  }

  tbody {
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    white-space: nowrap;
  }

  tr {
    width: 100%;
    display: inline-block;
    vertical-align: top;
  }

  th {
    border-bottom: 1px solid #f5f5f5;
  }

  td {
    border-bottom: 1px solid #e5e5e5;
  }


  }

<table class="table table-responsive">
  <thead>
    <tr>
      <th>X Title</th>
      <th>Y Title</th>
      <th>Z Title</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td> XXX </td>
      <td> YYY </td>
      <td> ZZZ </td>
    </tr>
  </tbody>
</table>

关于java - 响应表 bootstrap 隐藏列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40373024/

10-09 07:23