base_tutorial/test/testscroll.md
2025-04-09 10:17:16 +03:30

820 B

title input output
Scrollable code blocks markdown html_document
pre {
  max-height: 300px;
  overflow-y: auto;
}

pre[class] {
  max-height: 100px;
}

We have defined some CSS rules to limit the height of code blocks. Now we can test if these rules work on code blocks and text output:

# pretend that we have a lot of code in this chunk
if (1 + 1 == 2) {
  # of course that is true
  print(mtcars)
  # we just printed a lengthy data set
}

Next we add rules for a new class scroll-100 to limit the height to 100px, and add the class to the output of a code chunk via the chunk option class.output:

.scroll-100 {
  max-height: 100px;
  overflow-y: auto;
  background-color: inherit;
}
print(mtcars)