Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to choose the stacking order of spans?

I'm starting a project with Twitter Bootstrap, and quite like the responsive css, making the spans stack on top of each other when the viewport gets smaller.

Given the following design: http://jsfiddle.net/kJp6J/1/

Twitter responsive design

Is it possible to choose which block will be stacked first on small screens? In my case, I'd like the block on the right to appear first, followed by the blocks on the left.

Is there a way to do this?

like image 403
BenMorel Avatar asked Sep 01 '12 10:09

BenMorel


People also ask

What is stack order?

The stacking order describes the order in which HTML elements are positioned. By default, HTML elements are positioned in the following order: Root element(<html>) Non-positioned elements in the order they're defined(elements with no position described i.e. static)

How do you stack content in CSS?

Using CSS position property: The position: absolute; property is used to position any element at the absolute position and this property can be used to stack elements on top of each other. Using this, any element can be positioned anywhere regardless of the position of other elements.

How do you make a div appear in front of another?

You can use the CSS position property in combination with the z-index property to overlay an individual div over another div element. The z-index property determines the stacking order for positioned elements (i.e. elements whose position value is one of absolute , fixed , or relative ).


1 Answers

HTML

Wrap your content with .container, put that big block on the first place, add .pull-right so it will appear right:

<div class="container">
  <div class="row">
    <div class="span4 pull-right">
      <img src="http://placehold.it/280x180">
    </div>
    <div class="span8">
      <!-- ... -->
    </div>
  </div>
</div>

CSS

When on mobile, place it where it should be with float:none:

@media (max-width: 767px) {
  [class*="span"].pull-right {
    float: none;
}

Here's fiddle, I'll hope it works like you want it.

like image 136
Pavlo Avatar answered Oct 22 '22 21:10

Pavlo