css - how should I change the sequence of a list -


this code creates list of year + month

    var currentdate = datetime.now;             var list = new list<archiveviewmodel>();             (var startdate = currentdate; startdate >= new datetime(2012, 8, 1); startdate = startdate.addmonths(-1))             {                 list.add(new archiveviewmodel                 {                     month = startdate.month,                     year = startdate.year,                     formatteddate = startdate.tostring("mmmm, yyyy")                 });             }             return partialview("_archivesidebar", list); 

and code in razor

@foreach (var archive in model)     {         <ul>             <li>                 @html.actionlink(archive.formatteddate, "post", "archive", new { year = archive.year, month = archive.month }, null)             </li>         </ul>    } 

in case result

    august, 2013     july, 2013     june, 2013     may, 2013     april, 2013     march, 2013     february, 2013     january, 2013     december, 2012     november, 2012     october, 2012     september, 2012     august, 2012 

but want

august, 2013    july, 2013 june, 2013      may, 2013 april, 2013     march, 2013 february, 2013  january, 2013 december, 2012  november, 2012 october, 2012   september, 2012 august, 2012 

obviously data static, how should that??

you have not provided enough information on if data static or dynamic, kind of element wrapped inside.

i answer based on understanding of question.

you can use list format data in way want. put items in unordered list (i.e. ul) this:

html

<div id="somelist"> <ul> <li>august, 2013</li> <li>july, 2013</li> <li>june, 2013</li> <li>may, 2013</li> <li>april, 2013</li> <li>march, 2013</li> <li>february, 2013</li> <li>january, 2013</li> <li>december, 2012</li> <li>november, 2012</li> <li>october, 2012</li> <li>september, 2012</li> <li>august, 2012</li> </ul> </div> 

and, set width of wrapper div , use display-block on each list item fixed width makes pair of 2 in row. this:

css

#somelist {     width:500px;     padding:10px; } #somelist > ul {     display:inline-block;     padding: 0;     list-style:none; }  #somelist > ul > li {     display:inline-block;     width:200px;     padding:2px;     } 

here's sample: http://jsfiddle.net/3bwyj/1/

update

replace code following , use css have provided:

<div id="somelist">   <ul>     @foreach (var archive in model)         {           <li>               @html.actionlink(archive.formatteddate, "post", "archive", new { year = archive.year, month = archive.month }, null)           </li>         }   </ul>    </div> 

note have added div wrapper ul , don't forget change id of div somelist else.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -