javascript - using jQuery or CSS to swap around list items - is it possible? -
so have list perfect desktop need move them around mobile - show images need order them differently mobile , wondering if possible in css or jquery.
as can see screenshots, desktop left left, right right great mobile need have left, right, left, right etc.. cannot modiffy markup generated in smarty tpl need solution css or jquery have not idea how done though great if me on please :)
for desktop works fine, this:
item 1 | item 2 item 3 | item 4 item 5 | item 6 item 7 | item 8
for mobile, works this:
item 1 item 2 item 3 item 4 item 5 item 6 item 7 item 8
but, want instead mobile:
item 1 item 3 item 2 item 4 item 5 item 7 item 6 item 8
<ul class="subcategories clearfix"> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/butterfly-sofa-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-butterfly.jpg?t=1437997789" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/avatar-lounger-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-avatar.jpg?t=1437997872" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/twin-couch-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-twin.jpg?t=1437998079" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/versa-table-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-versa.jpg?t=1437998061" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/acoustic-sofa-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-acoustic.jpg?t=1437998265" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/pet-lounger-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-pet.jpg?t=1437996755" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/wing-ottoman-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/4/category-pane-wing-ottoman.jpg?t=1437998482" alt="" title="" /> </a> </li> <li class="ty-subcategories__item"> <a href="/interior/gold-class-bean-bags/fiorenze-leather-bean-bags/"> <img class="ty-pict ty-subcategories-img " src="/images/detailed/3/category-panel-fiorenze.jpg?t=1437998353" alt="" title="" /> </a> </li> </ul>
yet, css solution mobile version:
ul { line-height: 1em; } ul li { position: relative; } ul li:nth-child(4n - 2) { top: 1em; /* move down */ } ul li:nth-child(4n - 1) { top: -1em; /* move */ }
<ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> <li>item 4</li> <li>item 5</li> <li>item 6</li> <li>item 7</li> <li>item 8</li> </ul>
keep simple. idea swap rows every 4th element.
jsfiddle specific problem.
here responsive design solution. using translations swap rows, since height of images unknown.
using vw
unit allows site respond viewport width changes. naturally works screen sizes.
i've reformatted markup git rid of whitespaces between each li
. way images glued without margins.
since each li
inline-block
, following renders white space between each element:
<li> image1 </li> <li> image2 </li>
so, did changing to
<li> image1 </li><li> <!-- no spaces between each li tag --> image2 </li>
Comments
Post a Comment