Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Convert Horizontal <table> to vertical using CSS

Convert Horizontal <table> to vertical using CSS

Scheduled Pinned Locked Moved Web Development
questioncsscomannouncement
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I have a <table> like this:

    Name Mike Watson
    Title Accountant
    Department Finance

    and I want to list it this way using CSS:

    Name
    Mike Watson

    Title
    Accountant

    Department
    Finance

    How can I do that please?

    Technology News @ www.JassimRahma.com

    S E S 3 Replies Last reply
    0
    • J Jassim Rahma

      Hi, I have a <table> like this:

      Name Mike Watson
      Title Accountant
      Department Finance

      and I want to list it this way using CSS:

      Name
      Mike Watson

      Title
      Accountant

      Department
      Finance

      How can I do that please?

      Technology News @ www.JassimRahma.com

      S Offline
      S Offline
      Salman _Memon
      wrote on last edited by
      #2

      <style>
      table {
      width: 100%
      }
      table,
      th,
      td {
      border: 1px solid black;
      border-collapse: collapse;
      }
      th,
      td {
      padding: 5px;
      text-align: left;
      }
      </style

      <h2>Horizontal Headings:</h2>

      <table>
      <tr>
      <th>Name</th>
      <th>Telephone</th>
      <th>Telephone</th>
      </tr>
      <tr>
      <td>Bill Gates</td>
      <td>555 77 854</td>
      <td>555 77 855</td>
      </tr>
      </table>

      <h2>Vertical Headings:</h2>

      <table>
      <tr>
      <th>Name:</th>
      <td>Bill Gates</td>
      </tr>
      <tr>
      <th>Telephone:</th>
      <td>555 77 854</td>
      </tr>
      <tr>
      <th>Telephone:</th>
      <td>555 77 855</td>
      </tr>
      </table

      >

      Sam

      1 Reply Last reply
      0
      • J Jassim Rahma

        Hi, I have a <table> like this:

        Name Mike Watson
        Title Accountant
        Department Finance

        and I want to list it this way using CSS:

        Name
        Mike Watson

        Title
        Accountant

        Department
        Finance

        How can I do that please?

        Technology News @ www.JassimRahma.com

        E Offline
        E Offline
        Erick Shawn
        wrote on last edited by
        #3

        Hi Jassim, More than making a table it is better to make it more attractive. http://www.w3schools.com/css/css\_table.asp\[[^](http://www.w3schools.com/css/css_table.asp "New Window")]

        1 Reply Last reply
        0
        • J Jassim Rahma

          Hi, I have a <table> like this:

          Name Mike Watson
          Title Accountant
          Department Finance

          and I want to list it this way using CSS:

          Name
          Mike Watson

          Title
          Accountant

          Department
          Finance

          How can I do that please?

          Technology News @ www.JassimRahma.com

          S Offline
          S Offline
          stef chui
          wrote on last edited by
          #4

          Hi Jassim Rahma, You click the do it will send the result.

          <head>
          <title></title>
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
          </head>
          <body>
          <script>
          $(document).ready(function(){
          $("a").click(function(){
          $("table").each(function() {
          var $this = $(this);
          var newrows = [];
          var i = 0;
          $this.find("tr").each(function(){
          $(this).find("td").each(function(){
          i++;
          if(newrows[i] === undefined) { newrows[i] = $(""); }
          newrows[i].append($(this));
          });
          });
          $this.find("tr").remove();
          $.each(newrows, function(){
          $this.append(this);
          });
          });

          return false;
          

          });
          });
          </script>

          Name

          Mike Watson

          Title

          Accountant

          Department

          Finance

          Do it.

          </body>
          </html>

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups