如何使用Jquery mobile将表格设置为响应式?

时间:2012-12-18 10:10:23

标签: php jquery html css jquery-mobile

如何使用Jquery mobile将表格设置为响应式?

目前我正在为magento定制jquery移动主题。但表格没有响应。当移动屏幕太小时,会出现水平滚动。

我在here和jquery.mobile-1.0b3.min.css中添加了一个css。

.ui-table {
   border: 0;
   border-collapse: collapse;
   padding: 0;
   width: 100%;
}
.ui-table th,
.ui-table td {
  line-height: 1.5em;
  text-align: left;
  padding: .4em .5em;
  vertical-align:top;
}
.ui-table th {
  font-weight: bold;
}
.ui-table caption {
  text-align:left;
  margin-bottom:1.4em;
  opacity:50%;
}

/* Add strokes between each row */
.table-stroke thead th {
  border-bottom: 1px solid #d6d6d6; /* non-RGBA fallback */
  border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.table-stroke tbody th,
.table-stroke tbody td {
  border-bottom: 1px solid #e6e6e6; /* non-RGBA fallback  */
  border-bottom: 1px solid rgba(0, 0, 0, .05);
}


/* Add alternating row stripes */
.table-stripe tbody tr:nth-child(odd) td,
.table-stripe tbody tr:nth-child(odd) th {
  background-color: #eeeeee; /* non-RGBA fallback  */
  background-color: rgba(0,0,0,0.04);
}
/* Add stroke to the header and last item */
.table-stripe thead th,
.table-stripe tbody tr:last-child {
  border-bottom: 1px solid #d6d6d6; /* non-RGBA fallback  */
  border-bottom: 1px solid rgba(0, 0, 0, .1);
}

但它仍然没有用。我的CSS和JS是,

  1. jquery.mobile-1.0b3.min.css
  2. 的jquery-1.6.2.min.js
  3. jquery.mobile-1.0b3.min.js
  4. 我错过了什么吗?

2 个答案:

答案 0 :(得分:1)

您可能对JQM 1.3发布的Responsive TablesResponsive Grids感兴趣。

答案 1 :(得分:1)

已有一个用于响应式表格视图的活动jQM插件,您可以在此处找到它:https://github.com/frequent/tableview

演示可以在这里找到:http://www.franckreich.de/jqm/tableview/demo.html

如果您需要更多信息,可以随时询问开发人员,他是此社区的活跃成员:https://stackoverflow.com/users/536768/frequent

警告:

此实现需要两个额外的js文件+一个CSS。