ProGrammer
ProGrammer

Reputation: 1031

Full-width column below expanded row

Background
I have put together a simple table with a collapsed text object, which when clicked on, expands to reveal more details associated with the heading/title.

The code: JSFiddle

The Problem
When the row element expands, it forces the content into the same column as its title, instead of taking up a full row's width to show the text underneath all three columns. Similar to this:

Normal State / Collapsed:
 -----------------------------------------
| > Title to expand   |    x    |    ✓    |
 -----------------------------------------

Intended State / Expanded:
 -----------------------------------------
| ⌄ Title to expand   |    x    |    ✓    |
|   Item explanation - spans entire width |
 -----------------------------------------

Not intended when expanded (problem):
 -----------------------------------------
| ⌄ Title to expand   |    x    |    ✓    |
|   Item explanation -                    |
|   spans entire width                    |
 -----------------------------------------
or
 -------------------------------------------------------------
| ⌄ Title to expand                       |    x    |    ✓    |
|   Item explanation - spans entire width                     |
 -------------------------------------------------------------

Intended Outcome
The above (middle) diagram shows what the end result should look like. I know about using display: none; to hide rows, however, I do not want the content in a separate row so to speak but rather "expand" the one it is in.

Question
How would I expand the item in a way that the explanation fills the width of the entire row below the 3 columns? Any Help is appreciated here, I'm sure there are some CSS experts out there. I hope the examples make things clear, let me know if you require further information. I'm always more than happy to elaborate. Cheers.

Upvotes: 1

Views: 739

Answers (1)

Taki
Taki

Reputation: 17654

put the icons in the same td and float them to the right with some margin-right :

@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300italic,400,600");
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
/* Reset */

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
  display: block;
}

body {
  line-height: 1;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

body {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 18pt;
  line-height: 1.75em;
  font-weight: 300;
  letter-spacing: 1px;
  color: #3a3939;
  text-shadow: 0 0 0.5px rgba(58, 57, 57, 0.25);
  -webkit-text-stroke: 0.25px;
}

p,
ul,
ol,
dl,
table {
  margin-bottom: 1em;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

th,
td {
  text-align: center;
  padding: 16px;
}

th:first-child,
td:first-child {
  text-align: left;
}

tr:nth-child(even) {
  background-color: #f2f2f2
}

.fa-check {
  color: green;
}

.fa-remove {
  color: red;
}

.icon {
  text-decoration: none;
}

.icon:before {
  display: inline-block;
  font-family: FontAwesome;
  font-size: 1.25em;
  text-decoration: none;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon>.label {
  display: none;
}

.tooltipz {
  position: relative;
  display: inline-block;
}

.tooltipz .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 10px;
  position: absolute;
  z-index: 1;
  bottom: 150%;
  left: 50%;
  margin-left: -100px;
  font-size: 15px;
  line-height: normal;
}

.tooltipz .tooltiptext::after {
  content: " ";
  position: absolute;
  top: 100%;
  /* At the bottom of the tooltip */
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: black transparent transparent transparent;
}

.tooltipz:hover .tooltiptext {
  visibility: visible;
}

summary::-webkit-details-marker {
  color: #00ACF3;
  margin-right: 2px;
}

summary:focus {
  outline-style: none;
}

article>details>summary {
  margin-top: 16px;
}

details>p {
  margin-left: 24px;
  text-align: justify;
}

details details {
  margin-left: 36px;
}

td .fa {
  float: right;
  margin-right: 10%;
  margin-top: 2%;
}
<div class="table-wrapper default">
  <table>
    <tr>
      <td>First row
        <i class="fa fa-check"></i>
        <i class="fa fa-check"></i>
      </td>
    </tr>
    <tr>
      <td>
        <i class="fa fa-check"></i>
        <i class="fa fa-remove"></i>
        <details>
          <summary>Expanded Row</summary>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec in metus a nisl molestie mattis a in mauris. Vestibulum orci metus, tincidunt quis commodo nec, pellentesque quis erat.</p>
        </details>
      </td>
    </tr>
    <tr>
      <td>
        Last Row
        <i class="fa fa-check"></i>
        <i class="fa fa-remove"></i>
      </td>
    </tr>
  </table>
</div>

Upvotes: 1

Related Questions