Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:19:09+00:00 2026-06-03T21:19:09+00:00

I’ve been implementing a grid view of some content – and I have it

  • 0

I’ve been implementing a grid view of some content – and I have it implemented as a genuine unordered list to get a nice block, visual look. Now I’m being tasked to implement the same data, but as a table. There are actions you can do on this data as well. The figure is meant to show switching, but the lists can be longer.

Grid/Table View

Now, I have a sense that I could use the existing unordered list structure, and add elements to it and then “fake” a table view, which actually doesn’t seem that much harder. Or I could do it the other way, change everything to a table view then implement the grid view with CSS.

My question is, what are some approaches to do this? I could double up my markup – implementing both, and then switching between. But in an AJAX heavy application, I’m doing twice the DOM manipulations to add this stuff.

Is there a best practice for being able to toggle a view like this? I’m looking for ideas and working examples, especially.


I’ve updated this with a jsFiddle showing an unordered list as the basis. Does anyone have any example CSS that uses a table as the basis?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:19:11+00:00Added an answer on June 3, 2026 at 9:19 pm

    Well, nobody took me up on doing this with a table-centric approach, so below is the code for a ul>li centric approach:

    HTML:

    <div class="controls">
        <a href="#" class="list active">List</a>
        <a href="#" class="grid">Grid</a>
    </div>
    
    <div id="wrapper">
    <ul class="list">
        <li class="header"><h2 class="name">Name</h2>
            <p class="date">Start Date</p>
            <p class="title">Title</p>
            <div class="image">Image</div></li>
        <li class="even"><h2 class="name">Adam Ant</h2>
            <p class="date">1995</p>
            <p class="title">Specialist</p>
            <div class="image"><img src="http://www.placehold.it/200x200" alt=""></div></li>
        <li class="odd"><h2 class="name">Brian Box</h2>
            <p class="date">2005</p>
            <p class="title">Specialist</p>
            <div class="image"><img src="http://www.placehold.it/200x200" alt=""></div></li>
        <li class="even"><h2 class="name">Clara Clock</h2>
            <p class="date">2010</p>
            <p class="title">Manager</p>
            <div class="image"><img src="http://www.placehold.it/200x200" alt=""></div></li>
        <li class="odd"><h2 class="name">Darla Dock</h2>
            <p class="date">1996</p>
            <p class="title">Editor</p>
            <div class="image"><img src="http://www.placehold.it/200x200" alt=""></div></li>
    </ul>
    </div>​
    

    CSS:

    body {
        font-family: sans-serif;
    }
    .controls {
        text-align: right;
        width: 500px;
    }
    .controls a {
        background-color: #000;
        color: #fff;
        display: inline-block;
        padding: 6px;
        text-decoration: none;
    }
    .controls a.active {
        background-color: blue;
    }
    
    #wrapper .list li { 
        width: 500px; 
        position: relative;
        height: 30px;
    }
    #wrapper .list li.odd * {
        background-color: #eee;
    }
    #wrapper .list li.header {
        background-color: #666;
        color: #fff;
    }
    #wrapper .list li * {
        position: absolute;
        line-height: 1;
        top: 0;
        display: block;
        height: 30px;
    }
    #wrapper .list li h2.name {
        left: 0;
        width: 150px;
    
    }
    #wrapper .list li p.date {
        left: 150px;
        width: 100px;
    }
    #wrapper .list li p.title {
        left: 250px;
        width: 100px;
    }
    #wrapper .list li div.image {
        left: 350px;
        width: 150px;
    }
    #wrapper .list li div.image img {
        height: 20px;
        width: 20px
        margin: 0 auto;
    }
    
    #wrapper .grid li { 
        display: inline-block;
        width: 200px; 
        height: 200px;
        position: relative;
        overflow: hidden;
    }
    #wrapper .grid li.header {
        display: none;
    }
    #wrapper .grid h2.name {
        background-color: rgba(0,0,0,0.5);
        color: #fff;
        position: absolute;
        left: 0;
        top: 0;
        width: 200px;
        line-height: 2;
        height: 30px;
    }
    #wrapper .grid p.date {
        display: none;
    }
    #wrapper .grid p.title {
        display: none;
    }
    

    ​

    JavaScript (using MooTools):

    $$('a').addEvent('click', function(){
        $$('.controls a').toggleClass('active');
        $$('ul').toggleClass('list').toggleClass('grid');
        return false;
    })
    

    ​

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.