# Making images maintain a certain distance

**URL:** <https://forum.kirupa.com/t/making-images-maintain-a-certain-distance/179813>\
**Category:** Uncategorized\
**Created:** [February 23, 2006, 5:10am UTC](https://forum.kirupa.com/t/making-images-maintain-a-certain-distance/179813 "2006-02-23T05:10:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ozymandias](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ozymandias/32/1997_2.png) [@Ozymandias](https://forum.kirupa.com/u/Ozymandias)\
**Post date:** [February 23, 2006, 5:10am UTC](https://forum.kirupa.com/t/making-images-maintain-a-certain-distance/179813/1 "2006-02-23T05:10:58Z")

</div>

I’m making a thumbnail gallery where I want the image you click on to expand, while the pictures to either side move out of the way. I managed to get it working using this to move the pictures:

“Value” is just a number assigned to each picture, so this does one thing to the pictures to the right of the target, and one thing to the pictures on the left.

// for (q=0; q\<total; q++) {  
// if (q\<this.Value) {  
// mcs[q].\_x = mcs[q+1].\_x-20-mcs[q].\_width;  
// } else if (q\>this.Value) {  
// mcs[q].\_x = mcs[q-1].\_x+20+mcs[q-1].\_width;  
// }  
// }

The problem with this is it doesn’t seem to work if you have more than one picture changing size at once, which is a feature I’d like to have. Also, the pictures tend to squish together at first before settling out to their proper spacings.

Does anyone have a better/more flexible way of doing this?
