TablesTutorials

how to create a responsive Tables using CSS Flexbox

how to create a responsive Tables using CSS Flexbox

Before We Start

Every developers need, clean and modern elements to develop their websites, It contain pictures and a user interface element within a website. The most important one and the first section that the user sees when he/she enters a website. how to create a responsive Tables using CSS Flexbox

So if you are a person who wishes to develop a website, you have to know how to create that properly.

how to create a responsive Tables using CSS Flexbox

Download Udemy paid courses FREE

We are here to solve your problem. In this article we discuss how to create this elements. Before we start please read the below articles which easier you to understand the process, if you are new to development.

Step 1 – Add HTML

It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.

<div class="container-fluid" style="margin-top: 10px">
  <div class="table-row header">
    <div class="column index">#</div>
    <div class="wrapper attributes">
      <div class="wrapper title-comment-module-reporter">
        <div class="wrapper title-comment">
          <div class="column title">Title</div>
          <div class="column comment">Comment</div>
        </div>
        <div class="wrapper module-reporter">
          <div class="column module">Module</div>
          <div class="column reporter">Reporter</div>
        </div>
      </div>
      <div class="wrapper status-owner-severity">
        <div class="wrapper status-owner">
          <div class="column status">Status</div>
          <div class="column owner">Owner</div>
        </div>
        <div class="column severity">Severity</div>
      </div>
    </div>
    <div class="wrapper icons">
      <div title="Watch" class="column watch">
        <span class="glyphicon glyphicon-eye-open"></span>
      </div>
      <div title="Add comment" class="column add-comment">
        <span class="glyphicon glyphicon-comment"></span>
      </div>
    </div>
    <div class="wrapper dates">
      <div class="column date">Created</div>
      <div class="column date">Updated</div>
      <div class="column date">Due</div>
    </div>
  </div>

  <div class="table-row">
    <div class="column index">1</div>
    <div class="wrapper attributes">
      <div class="wrapper title-comment-module-reporter">
        <div class="wrapper title-comment">
          <div class="column title">App crashes when dragged by title bar</div>
          <div class="column comment">Eddie, can you please take a look. We want this fixed pretty soon.</div>
        </div>
        <div class="wrapper module-reporter">
          <div class="column module">Main App</div>
          <div class="column reporter">Ravan</div>
        </div>
      </div>
      <div class="wrapper status-owner-severity">
        <div class="wrapper status-owner">
          <div class="column status"><span class="label label-primary">Open</span></div>
          <div class="column owner">Eddie</div>
        </div>
        <div class="column severity high">High</div>
      </div>
    </div>
    <div class="wrapper icons">
      <div class="column watch"><span class="glyphicon glyphicon-eye-open active" /></div>
      <div class="column add-comment"><span class="glyphicon glyphicon-comment" /></div>
    </div>
    <div class="wrapper dates">
      <div class="column date">Feb-1, 2016</div>
      <div class="column date">Mar-13, 2016</div>
      <div class="column date">Apr-4, 2016</div>
    </div>
  </div>

  <div class="table-row">
    <div class="column index">2</div>
    <div class="wrapper attributes">
      <div class="wrapper title-comment-module-reporter">
        <div class="wrapper title-comment">
          <div class="column title">Unable to save the data when using Enter key instead of clicking on submit button.</div>
          <div class="column comment">Let me take this up.</div>
        </div>
        <div class="wrapper module-reporter">
          <div class="column module">Save Screen</div>
          <div class="column reporter">Kiran</div>
        </div>
      </div>
      <div class="wrapper status-owner-severity">
        <div class="wrapper status-owner">
          <div class="column status"><span class="label label-primary">Open</span></div>
          <div class="column owner">Vasan</div>
        </div>
        <div class="column severity medium">Medium</div>
      </div>
    </div>
    <div class="wrapper icons">
      <div class="column watch"><span class="glyphicon glyphicon-eye-open active" /></div>
      <div class="column add-comment"><span class="glyphicon glyphicon-comment active" /></div>
    </div>
    <div class="wrapper dates">
      <div class="column date">Mar-3, 2016</div>
      <div class="column date">Apr-4, 2016</div>
      <div class="column date">May-15, 2016</div>
    </div>
  </div>

  <div class="table-row">
    <div class="column index">3</div>
    <div class="wrapper attributes">
      <div class="wrapper title-comment-module-reporter">
        <div class="wrapper title-comment">
          <div class="column title">Improper alignment in Export section</div>
          <div class="column comment">Hey, I am not able to reproduct this. Can you please attach a screenshot?</div>
        </div>
        <div class="wrapper module-reporter">
          <div class="column module">Exports</div>
          <div class="column reporter">Ravan</div>
        </div>
      </div>
      <div class="wrapper status-owner-severity">
        <div class="wrapper status-owner">
          <div class="column status"><span class="label label-success">In Progress</span></div>
          <div class="column owner">Pieta</div>
        </div>
        <div class="column severity low">Low</div>
      </div>
    </div>
    <div class="wrapper icons">
      <div class="column watch"><span class="glyphicon glyphicon-eye-open" /></div>
      <div class="column add-comment"><span class="glyphicon glyphicon-comment active" /></div>
    </div>
    <div class="wrapper dates">
      <div class="column date">Apr-14, 2016</div>
      <div class="column date">May-5, 2016</div>
      <div class="column date">Jun-6, 2016</div>
    </div>
  </div>

</div>

Step 2 – Add CSS

Download Udemy paid courses FREE

We use some external CSS link to this code. No need to worry about this, copy and paste below code between <style></style> tag.

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>

Copy and paste below code in your HTML editor between <style></style> tag.

<style>
/*
 * Define the widths: play around with these 
 * to get a best fit.
 */
/*
 * Basic styles, good for a large display. Everything fits in
 * one row, no wrapping. All text based cells grow equally.
 */
.table-row {
  display: flex;
  display: -webkit-flex;
  flex-direction: row;
  -webkit-flex-direction: row;
  flex-wrap: no-wrap;
  -webkit-flex-wrap: no-wrap;
  width: 100%;
  padding-left: 15px;
  padding-right: 15px;
}
.wrapper {
  display: flex;
  display: -webkit-flex;
  flex-direction: row;
  -webkit-flex-direction: row;
}
.column {
  flex-grow: 0;
  -webkit-flex-grow: 0;
  flex-shrink: 0;
  -webkit-flex-shrink: 0;
  vertical-align: top;
}
.index {
  width: 25px;
}
.title {
  width: 220px;
}
.module {
  width: 110px;
}
.reporter {
  width: 85px;
}
.status {
  width: 95px;
}
.owner {
  width: 75px;
}
.severity {
  width: 80px;
}
.watch,
.add-comment {
  width: 18px;
}
.date {
  width: 110px;
}
.index {
  text-align: center;
}
.title {
  font-weight: bold;
  color: #337AB5;
}
.comment {
  width: 120px;
}
.title,
.comment {
  flex-grow: 1;
  -webkit-flex-grow: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-right: 4px;
}
.date {
  width: 110px;
  text-align: right;
  padding-right: 4px;
}
/* growable wrappers */
.title-comment,
.title-comment-module-reporter,
.attributes {
  flex-grow: 1;
  -webkit-flex-grow: 1;
}
/*
 * Media queries: optimize for different screen widths.
 */
/*
 * Media breaks.
 */
@media all and (max-width: 1236px) {
  .title-comment {
    flex-direction: column;
    -webkit-flex-direction: column;
    width: 220px;
  }
  .title-comment div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
  .title-comment > div {
    width: 100%;
  }
  .module-reporter,
  .status-owner {
    flex-direction: column;
    -webkit-flex-direction: column;
  }
  .module-reporter div,
  .status-owner div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
}
@media all and (max-width: 956px) {
  .module-reporter {
    flex-direction: row;
    -webkit-flex-direction: row;
  }
  .title-comment-module-reporter {
    flex-direction: column;
    -webkit-flex-direction: column;
    width: 220px;
  }
  .title-comment-module-reporter div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
  .title-comment-module-reporter > div {
    width: 100%;
  }
  .status-owner-severity {
    flex-direction: column;
    -webkit-flex-direction: column;
  }
  .status-owner-severity div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
  .icons {
    flex-direction: column;
    -webkit-flex-direction: column;
  }
  .icons div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
  .dates {
    flex-direction: column;
    -webkit-flex-direction: column;
  }
  .dates div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
}
@media all and (max-width: 528px) {
  .table-row {
    padding-left: 4px;
    padding-right: 4px;
  }
  .attributes {
    flex-direction: column;
    -webkit-flex-direction: column;
    width: 220px;
  }
  .attributes div {
    flex-grow: 0;
    -webkit-flex-grow: 0;
  }
  .attributes > div {
    width: 100%;
  }
  .module-reporter,
  .status-owner {
    flex-direction: row;
    -webkit-flex-direction: row;
  }
}
/*
 * General good-look styles
 */
.table-row {
  border-bottom: 1px solid #e0e0e0;
  border-collapse: collapse;
  padding-top: 2px;
}
.table-row.header {
  background-color: #FFEEDB;
  font-weight: bold;
  padding-top: 6px;
  padding-bottom: 6px;
}
.glyphicon {
  color: #DDDDDD;
}
.header .glyphicon {
  color: #333;
}
.glyphicon-eye-open.active {
  color: blue;
}
.glyphicon-comment.active {
  color: #3EBB0D;
}
.glyphicon:hover {
  color: #666;
  cursor: pointer;
  text-decoration: underline;
}
.reporter {
  color: #999999;
}
.comment {
  font-style: italic;
}
.severity.high {
  color: red;
}
.severity.medium {
  color: blue;
}
.severity.low {
  color: green;
}

</style>

At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want.Enjoy it.

how to create a responsive Tables using CSS Flexbox

Video Tutorial

Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.

Download Udemy paid courses FREE


Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button