问题
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