user777
user777

Reputation: 894

Inside a CSS table container, how can I move a single table-cell into the next row by touching only its CSS?

I have the following HTML:

<div class='container'>
  <div class='first'>test</div>
  <div class='second'>test</div>
</div>

accompied by the following CSS:

.container {
  display: table;
  width: 90%;
  background: yellow;
}

.first {
  display: table-cell;
  background: red;
}

.second {
  display: table-cell;
  background: blue;
}

(Also: http://codepen.io/zssz/pen/GodBqQ)

How can I achieve that the second/blue div sits right below the first/red div, by ONLY changing the CSS of .second?

Thank you

(I have no control over the container CSS in this situation)

Upvotes: 0

Views: 98

Answers (1)

Lu&#237;s P. A.
Lu&#237;s P. A.

Reputation: 9739

You can do this:

CSS

.second {
  display: table-row;
  background: blue;
}

DEMO HERE

Upvotes: 1

Related Questions