1

I am using display:table and display:table-cell to build my columns.

Is it possible to have a column inside another column span across 2 columns?

I tried column-span: all but that does not seem to work?

http://jsfiddle.net/infatti/sSK8u/

.column-container {
  display: table;
  border-collapse: collapse;
  margin-bottom: 10px;
}
.column-container .col-5-with-rule {
  display: table-cell;
  vertical-align: top;
  width: 150px;
  border-left: none;
  padding-left: 0;
  padding-right: 9px;
}
.column-container .col-5-with-rule ~ .col-5-with-rule {
  border-left: 1px solid #d1d1d1;
  padding-left: 9px;
  padding-right: 9px;
}

.column-container .col-span-2 {
  column-span: all;
}

<div class="column-container"><!-- columns container -->
  <div class="col-5-with-rule"><!-- column -->
    <p>Table cell</p>
      <div class="col-span-2"><!-- column span -->
        <p>Make me span into 2 columns.</p>
      </div><!-- #column span -->
  </div><!-- #column -->
  <div class="col-5-with-rule"><!-- column -->
    <p>Table cell</p>
  </div><!-- #column -->
</div><!-- #columns container -->

2 Answers 2

1

Depending on the context you'd like to use this in, you can build your grid out with Bootstrap.

Here's the HTML mark-up to achieve what you want using Bootstrap 3

<div class = "row">
    <div class = "col-xs-2">
        Table cell
    </div>
    <div class = "col-xs-2">
        Table cell
    </div>
</div>
<div class = "row">
    <div class = "col-xs-4">
        Make me span into 2 columns.        
    </div>
</div>

Fiddle here

Mark-up for Bootstrap 2

<div class = "row">
    <div class = "span2">
        Table cell
    </div>
    <div class = "span2">
        Table cell
    </div>
</div>
<div class = "row">
    <div class = "span4">
        Make me span into 2 columns.        
    </div>
</div>

Fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

is there a way to do the same in bootstrap 2?
0

You can set col-span-2s position to absolute and then position it wherever you want to.

Fiddle: http://jsfiddle.net/sSK8u/2/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.