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/
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?
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)
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.
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 ).
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>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With