6๐
I refered to a UI framework which now Iโm using, name as iView.
Of course, they also support striped table component. So I wondered how they do like that.
.ivu-table-stripe .ivu-table-body tr:nth-child(2n) td,
.ivu-table-stripe .ivu-table-fixed-body tr:nth-child(2n) td {
background-color: #f8f8f9;
}
As you can see, CSS support for handling each case of even and odd by using nth-child()
. There is no more simple way to do like that.
further more, you can use more complex formula as a parameter like this :
(an + b).
W3School Nth-child Example maybe helpful for you.
๐คwormwlrm
- [Vuejs]-CopyWebpackPlugin isn't copying static files to output directory
- [Vuejs]-ERROR in renderer.js from UglifyJs Unexpected token punc ยซ(ยป
4๐
You can use index
:
<div v-for="(item, index) in myData">
<div v-if="" :class="{'odd-cell': index % 2 === 1, 'even-cell': index % 2 === 0}">
<p> {{item.a}} </p>
<p> {{item.b}} </p>
</div>
</div>
But there are better solution with css nth-child
div:nth-child(odd) {
background: red;
}
div:nth-child(even) {
background: blue;
}
๐คittus
- [Vuejs]-Vue 2 โ Communication between components (sending and receiving data)
- [Vuejs]-How does validation work in Vue.js 2.0?
Source:stackexchange.com