Responsive scroll background issue

北战南征 提交于 2019-12-11 05:29:50

问题


I have the following CSS, trying to make a responsive table-like design.

.table {
  display: flex;
  width: 100%;
  flex-direction: column;
  overflow-x: auto;
}

.table__row {
  display: flex;
  flex-flow: row nowrap;
}

.table__column {
  flex-shrink: 0;
  display: block;
  align-items: center;
  padding: .54rem 1.05rem;
  width: 300px;
  overflow-x: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

Here's a JSFiddle: https://jsfiddle.net/abuer473/

The problem is that when a user scrolls to the right, the background gets lost. How do I fix this?


回答1:


I was able to fix the issue by adding background to the columns of every even numbered row:-

css:

.table__row:nth-child(2n) > .table__column {
  background: #AAA;
}

or else you could write

css:

.table__row:nth-child(even) > .table__column {
  background: #AAA;
}

DEMO



来源:https://stackoverflow.com/questions/51344940/responsive-scroll-background-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!