2017-10-20 4 views
-1

Je veux savoir comment je peux désactiver le défilement (Fenêtre), mais autoriser le défilement sur la zone de texte. J'ai essayé ce code mais désactiver totalement tout:Comment désactiver le défilement sur un élément particulier avec jquery

$('html, body').css({ 
    overflow: 'hidden', 
    height: '100%' 
}); 
+1

Pouvez-vous fournir un violon de cela? – sjahan

+0

Peut-être que vous pourriez trouver cette question utile: [Masquer la barre de défilement sur une page HTML] (https://stackoverflow.com/questions/3296644/hiding-the-scrollbar-on-an-html-page) – 3Dos

Répondre

0

Essayez ceci:

$('html, body').css({ 
    overflow: 'hidden', 
    height: '100%' 
}); 

Et dans la zone de texte ajouter:

style="overflow:scroll;" 
1

Une installation comme celle-ci pourrait fonctionner pour vous?

<div class="container"> 
    <h1>heading</h1> 
    <div class="scrollable"> 
     Text that will scroll. Text that will scroll. Text that will scroll. Text that will scroll. Text that will scroll. Text that will scroll. Text that will scroll. Text that will scroll. Text that will scroll. 
    </div> 
</div> 

<style> 
.container {height: 110px; width:100px; overflow:hidden;} 
.scrollable {overflow:auto;width:100%;height:30px} 
</style> 

ici est un codepen https://codepen.io/idlethumbs/pen/WZmEgQ