I have this code that pulls text from text file and displays it in pre-code block, the problem is that I’m only able to scroll the entire page (with body overflow enabled) but I can’t scroll div itself, even if I force display of scrollbar it stays unactive. What is my mistake here?
<body style="overflow:hidden">
<div style="margin: 0;padding: 0; height:100%; width: 100%; border: none; overflow: auto;">
<pre style="margin: 0;padding: 0; border: none; overflow: auto;">
<code> <?php echo $content?> </code>
</pre>
</div>
</body>
I’ve tried changing width/height to all available values, and overflow settings too.
2
Answers
You need to give the
div
orpre
a specific "height" so that it can be scrolledlike:
You need a
height
that’s different from your current100%
. For exampleheight: 100vh
. This will make sure that the size of the container equals to the size of the view-port in height and then you will have a scroll for it.