I have a DT
within a Rmarkdown
and I would like an image to pop up when hovering over table data.
What i have so for seems to work but it distorts the datatable
.
It increases the table rows height to fit the image. I have tried to reduce the row sizes via css
but with no luck.
This is the Rmarkdown
I have so far:
---
title: "Untitled"
author: "dimitris_ps"
date: "3 September 2016"
output: html_document
---
<style type="text/css">
.imgTooltip {
visibility: hidden;
}
.ItemsTooltip:hover .imgTooltip {
visibility: visible;
}
td {
height: 14px;
}
</style>
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(DT)
df <- structure(list(a = c("<a class="ItemsTooltip" href="http://www.example.com" target="_blank"><img class="imgTooltip" src="https://i.stack.imgur.com/uSSEu.jpg"/>my stackoverflow Avatar</a>",
"<a class="ItemsTooltip" href="http://www.example.com" target="_blank"><img class="imgTooltip" src="https://i.stack.imgur.com/uSSEu.jpg"/>my stackoverflow Avatar</a>"
), b = c("<a class="ItemsTooltip" href="http://www.example.com" target="_blank"><img class="imgTooltip" src="https://i.stack.imgur.com/uSSEu.jpg"/>my stackoverflow Avatar</a>",
"<a class="ItemsTooltip" href="http://www.example.com" target="_blank"><img class="imgTooltip" src="https://i.stack.imgur.com/uSSEu.jpg"/>my stackoverflow Avatar</a>"
)), .Names = c("a", "b"), row.names = c(NA, -2L), class = "data.frame")
```
```{r}
datatable(df, escape=c(FALSE, FALSE))
```
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…