在 Rmarkdown 中显示大图

mat*_*mat 3 html css r-markdown

我试图在 Rmarkdown html 输出中显示大图像而不自动调整其大小。为此,我想将图像放置在div可以沿 x 轴和 y 轴滚动的元素(小于图像本身)中。

这是我迄今为止尝试过的:

---
title: "test"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

<style>
  .container {
    overflow: scroll !important;
    white-space: nowrap;
    max-width: 300px;
    max-height: 300px;
  }
</style>

<div class="container">
  <img src="https://images.hdqwalls.com/wallpapers/talking-to-the-moon-ym.jpg" width="2000px"/>
</div>
Run Code Online (Sandbox Code Playgroud)

我想要的是能够沿两个轴使用可滚动元素以原始大小显示图像。


编辑

这是我正在寻找的说明:

在此处输入图片说明

Rad*_*tić 5

嗯......当我运行(Knit)以下代码时:

---
title: "test"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

<style>
  .container {
    overflow: scroll !important;
    white-space: nowrap;
    max-width: 300px;
    max-height: 300px;
  }
  img {
    max-width: 1000%;
  }
</style>

<div class="container">
  <img src="https://images.hdqwalls.com/wallpapers/talking-to-the-moon-ym.jpg" width="2000px"/>
</div>
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出:

在此处输入图片说明

  • 有用!不知道当我测试你评论中的代码时发生了什么,我一定是输错了一些东西。谢谢。 (2认同)