Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Okay here's the problem. I've layouted new design and for example:
I have a postgrid with 12 elements in 3 rows (4x3)
so i'm looping with a foreach through the items and testing with n.IsLast()) but this works only for the last node ;/
So i have to say the code cout all and every 4th item have the class "column last" all the others class "column"
Some advanced techniques to solve this for layout purposes.
You can do this a little bit like so:
var i = 0;@foreach (var n in Model.Children) { <div class="@(i % 4 == 0 ? "column last" : "column")"> Content </div> i++;}
Check to see if the index of the item is divisible by 4?
if ((index % 4) == 0){ add class }
You will probably need to use index+1 if it is a zero based array.
Okay thanks. Both solutions did the trick, but i have to start with i = 1 because devison of zero :p
Thanks to you two thumbs up
High fived to you :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Count Elements and give Class * 4.7.1 MacroEngines
Okay here's the problem. I've layouted new design and for example:
I have a postgrid with 12 elements in 3 rows (4x3)
so i'm looping with a foreach through the items and testing with n.IsLast()) but this works only for the last node ;/
So i have to say the code cout all and every 4th item have the class "column last" all the others class "column"
Some advanced techniques to solve this for layout purposes.
You can do this a little bit like so:
Check to see if the index of the item is divisible by 4?
if ((index % 4) == 0)
{ add class }
You will probably need to use index+1 if it is a zero based array.
Okay thanks. Both solutions did the trick, but i have to start with i = 1 because devison of zero :p
Thanks to you two thumbs up
High fived to you :)
is working on a reply...