How does the loop in the following volist make each loop result in a different background color?
such as the effect
. acti{
width:100%;
height:70px;
border:1px dashed #7E54DC;
Background-color: #E7E7E7;
margin-bottom:5px;
font-size:12px;
}
" > <{$vo.ac_charge}>元 <{$vo.ac_place}> <{$vo.ac_time}>
Reply content:
How does the loop in the following volist make each loop result in a different background color?
such as the effect
. acti{
width:100%;
height:70px;
border:1px dashed #7E54DC;
Background-color: #E7E7E7;
margin-bottom:5px;
font-size:12px;
}
" > <{$vo.ac_charge}>元 <{$vo.ac_place}> <{$vo.ac_time}>
1. Add different classes through the index in the loop, such as C1, C2 ... Define the styles for these classes in styles.
2. Use the CSS selector to selector:nth-child(n) add a style to a child element. n can be a specific nth, starting from 1. It can also be an expression such as an :nth-child(2n) even-numbered, odd-numbered :nth-child(2n+1) item.
Set the properties of the corresponding background color class . And then eliminate the index value of the loop to take different class attributes
.bg0{}.bg1{}.bg1{}
The index value is taken at the time of the loop
{foreach $key $val}...{/foreach}
Try it, hope it helps you
function getRandomColor() { var strColor = '#'; for (var i = 0; i < 6; i++) { var currnet = Math.random() * 15 | 0; strColor += currnet.toString(16); } return strColor;}$(".acti").css('background-color',getRandomColor());
Oh ah, with JS to achieve a full random.
Are you doing webapp?