I'm using Bootstrap css lib. I know how to make striped table with this lib but how to make striped div's?
For ex, in tables you would do this:
<table id="newtable" class="table table-bordered table-striped fixedtable">
<thead>
<th>Date</th>
<th>Info</th>
<th>Price</th>
</thead>
<tbody>
<tr>
<td colspan="3">
<div>text 1</div>
<div>text 2</div>
<div>text 3</div>
<div>text 4</div>
</td>
</tr>
</tbody>
</table>
And I need to repeat that "styling" with divs like this:
<div class="row"><div class="col">Text 1 White BG</div></div>
<div class="row"><div class="col">Text 2 Grey BG</div></div>
<div class="row"><div class="col">Text 3 White BG</div></div>
<div class="row"><div class="col">Text 4 Grey BG</div></div>
Question is: How to make: <div>text 1</div>, <div>text 2</div>, <div>text 3</div>, <div>text 4</div>
striped?
use td div:nth-of-type(odd|even)
The following CSS3 example works in modern browsers
<style>
td div:nth-of-type(odd) {
background: #e0e0e0;
}
td div:nth-of-type(even) {
background: #FFFFFF;
}
</style>
<table id="newtable" class="table table-bordered table-striped fixedtable">
<thead>
<th>Date</th>
<th>Info</th>
<th>Price</th>
</thead>
<tbody>
<tr>
<td colspan="3">
<div>text 1</div>
<div>text 2</div>
<div>text 3</div>
<div>text 4</div>
</td>
</tr>
</tbody>
</table>
Add class legend to your container and then for every other row actually in the divs within that row you can apply a format
CSS
.legend .row:nth-of-type(odd) div {
background-color:antiquewhite;
}
.legend .row:nth-of-type(even) div {
background: #FFFFFF;
}
<div class="container legend">
<div class="row">
<div class="col-sm-2">text</div>
<div class="col-sm-2">more Text</div>
</div>
<div class="row">
<div class="col-sm-2">text</div>
<div class="col-sm-2">more Text</div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With