2013-05-31 5 views

Répondre

0

Vous pouvez essayer: Débordement caché pour cacher la barre de défilement, modifier certains css pour le rendre plus grand et seulement 1 js fonction pour centrer:

<div id="a" style="width:50px;height:50px;background-color:#0000FF;overflow:hidden"> 
    <div id="b" onclick="this.style.width='45px';this.style.height='45px';this.scrollIntoView()" style="width:30px;height:30px;background-color:#FF0000"></div> 
    <div id="c" onclick="this.style.width='45px';this.style.height='45px';this.scrollIntoView()" style="width:30px;height:30px;background-color:#00FF00"></div> 
</div> 

ici le script en action: http://jsfiddle.net/C5A6J/ ici la référence ScrollIntoView : https://developer.mozilla.org/en-US/docs/Web/API/element.scrollIntoView

Questions connexes