在Rmarkdown中显示大图

我试图在 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>
  <img src="https://images.hdqwalls.com/wallpapers/talking-to-the-moon-ym.jpg" width="2000px"/>
</div>

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


编辑

这是我正在寻找的说明:

回答

嗯......当我运行(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>
  <img src="https://images.hdqwalls.com/wallpapers/talking-to-the-moon-ym.jpg" width="2000px"/>
</div>

这是我得到的输出:

  • It works! Don't know what happened when I tested the code in your comment, I must have mistyped something. Thank you.

以上是在Rmarkdown中显示大图的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>