abi*_*hat 2 html css r leaflet r-markdown
我想在其中创建一个带有居中的传单小部件的html文档.
---
title: "Exemple"
author: "Antoine Bichat"
date: "31/08/2018"
output: html_document
---
```{r leaflet, fig.align="center"}
library(leaflet)
leaflet() %>%
addTiles() %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
```
Run Code Online (Sandbox Code Playgroud)
第一个想法fig.align="center"不起作用.
我找到了这个问题,并根据我的情况进行了调整:
<style>
/* resize the widget container */
.leaflet {
width: 80% !important;
}
/* center the widget */
div.leaflet-control-container {
margin: auto !important;
}
</style>
Run Code Online (Sandbox Code Playgroud)
但如果我不想拥有out.width100%(而且我不想),它就不起作用.
或许我做错了......其实我更喜欢100%R/ Rmarkdown解决方案,但我对一切都开放:)
尝试CSS代码margin: auto为.html-widget
---
title: "Exemple"
author: "Antoine Bichat"
date: "31/08/2018"
output: html_document
---
<style>
.html-widget {
margin: auto;
}
</style>
```{r leaflet, fig.align="center"}
library(leaflet)
leaflet() %>%
addTiles() %>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
```
Run Code Online (Sandbox Code Playgroud)
这将集中每个htmlwidget.你也可以把:
<style>
.leaflet {
margin: auto;
}
</style>
Run Code Online (Sandbox Code Playgroud)
仅用于定位传单.
| 归档时间: |
|
| 查看次数: |
477 次 |
| 最近记录: |