css - How do I position divs into 3 columns, reposition into 2 when on narrow screen -
yes, realise title of question poor. feel free improve it.
i'm trying build css page has following requirements.
- there 6 'boxes'.
- each pair of boxes has equal total height
- the middle pair (boxes 3 , 4) have equal height
- they should arranged on below mockup, in 3 columns on wide screen
- they should arranged on second mockup below, in 2 columns
- on narrow screen should arranged in single column
- there should no gap between box , 1 directly below/above it
- i trying done using twitter bootstrap it's not requirement
- i'd prefer 100% css solution on css+jquery/other js solution
- it's corporate website sadly, has work in ie8+ (ie7 nice too, although not must if can have reasonable fallback)
here's jsfiddle play with: http://goo.gl/o2yoy
you can combination of column-count
, media queries:
.inner{ width: 100%; display: inline-block; } #outer{ column-count:3; -webkit-column-count:3; /* safari , chrome */ -moz-column-count: 3; /* firefox */ } @media (max-width: 600px) { #outer{ column-count:2; -webkit-column-count:2; /* safari , chrome */ -moz-column-count: 2; /* firefox */ } } @media (max-width: 300px) { #outer{ column-count:1; -webkit-column-count:1; /* safari , chrome */ -moz-column-count: 1; /* firefox */ } }
demo: http://jsfiddle.net/6wwdx/1/
browser compatibility of column-count
: http://caniuse.com/#feat=multicolumn
Comments
Post a Comment