html - Div position with inline-block -
i'm trying make navigation area, div , 4 divs inside it.
i created list, , set inline-block divs class.
but cant set them horizontal position.
i want have hidden scroll, , make moves jquery, clicking on directional buttons bellow div.
you can see problem divs position here: http://jsfiddle.net/brtcg/1/
.divsroll { display: inline-block; margin:0; padding: 0; vertical-align: middle; } #main { width: 500px; height: 500px; border: 1px solid #000; overflow: scroll; margin: auto; }
thanks since now.
i believe you're trying achieve.
in css, you'll need set ul li
inline-block , make width of ul
account needed space (the 15px accounts space around elements):
#main ul { list-style-type: none; margin: 0; padding: 0; width: 2015px; } #main ul li { display: inline-block; }
i restructured jquery code, , scrolling functional (tested in firefox).
html changes:
<input type='button' value='<<' id="back"> <input type='button' value='>>' id="forward">
jquery:
$(document).ready(function() { $('#forward').click(function() { var leftpos = $('#main').scrollleft(); $("#main").animate({scrollleft: 505 + leftpos}, 'slow'); }); $('#back').click(function() { var leftpos = $('#main').scrollleft(); $("#main").animate({scrollleft: leftpos - 505}, 'slow'); }); });
Comments
Post a Comment