如题,代码如下:
```{css}
.ring {
align-items: center;
justify-content: center;
margin: auto;
width: 1.875rem;
height: 1.875rem;
border: 0.5px solid #317ef3;
border-radius: 50%;
box-sizing: border-box;
}
.className1 {
font-size: 18px;
color: red;
font-weight: bold;
text-align: center;
border-right: 1px solid #555;
background-color: lightgrey;
}
.className2 {
min-width: 100px;
text-align: center;
}
```
```{r}
library(DT)
set.seed(2022)
data <- data.frame(
type1 = sort(rep(LETTERS[1:20], 2)),
type2 = rep(c('NO', 'YES'), 20),
value1 = sample(200:2000, 40),
value2 = sample(200:2000, 40),
level = sample(1:5, 40, replace = TRUE)
)
datatable(data, options = list(
pageLength = 5,
columnDefs = list(
list(targets = 1, class = 'ring'),
list(targets = 2, class = 'className1'),
list(targets = c(3, 4), class = 'className2'),
list(targets = 5, class = 'dt-center')
)
))
```
效果如下: