0

I have a couple of Github profile "cards" created from here which I am embedding as Markdown in a RMarkdown page on a pkgdown website.

How would i go about adding a border to these? Anything i have found searching has been about using CSS or html to add borders to images rather than embeds like this.

Or alternatively change the background colour of them - they are white on a white page.

Thanks

hokeybot
  • 195
  • 5

1 Answers1

2

You can mix markdown and html code and even use css code chunks in your RMarkdown document to change the styling. In the document below, I put the metrics card in a div with class=bordered and then changed the border-style attribute for the bordered class:


title: "test"
output: html_document
editor_options: 
  chunk_output_type: console
---
    
```{css echo=FALSE}
.bordered{
  border-style: solid;
}
```

<div class="bordered">
![](https://metrics.lecoq.io/davidaarmstrong?template=classic&base=header%2C%20activity%2C%20community%2C%20repositories%2C%20metadata&base.indepth=false&base.hireable=false&base.skip=false&config.timezone=America%2FToronto)
</div>

Here's the result:

enter image description here


side-by-side

To put two side-by-side: you could use a flexbox strategy:

```{css echo=FALSE}
.wrapper {
  display: flex;
}

.left {
  flex: 50%;
  margin:15px; 
  border-style: solid;
}

.right {
  flex: 50%;
  margin:15px; 
  border-style: solid;
}
```

<div class="wrapper">
<div class="left">
![](https://metrics.lecoq.io/davidaarmstrong?template=classic&base=header%2C%20activity%2C%20community%2C%20repositories%2C%20metadata&base.indepth=false&base.hireable=false&base.skip=false&config.timezone=America%2FToronto)
</div>
<div class="right">
![](https://metrics.lecoq.io/davidaarmstrong?template=classic&base=header%2C%20activity%2C%20community%2C%20repositories%2C%20metadata&base.indepth=false&base.hireable=false&base.skip=false&config.timezone=America%2FToronto)
</div>
</div>

Here's the result:

enter image description here

DaveArmstrong
  • 18,377
  • 2
  • 13
  • 25
  • Thanks! This does work. Now I'm having trouble with layout. I'm trying to have two of these, each bordered, and aligned side-by-side on the page (and centred). I've tried playing with other CSS options but not having much luck. – hokeybot May 15 '23 at 08:24
  • I did try creating a new style with `align-items: center;` and wrapping both embeds in that, but it made a total mess of the entire page so I'm definitely doing something wrong! – hokeybot May 15 '23 at 08:51
  • 1
    @hokeybot I just updated the answer with a possible solution. This employs a slightly modified version of a suggestion in [this answer](https://stackoverflow.com/questions/17217766/two-divs-side-by-side-fluid-display). – DaveArmstrong May 15 '23 at 13:24
  • Thanks again. Works perfectly. I got very close with my own experimentation but not quite there! I added this to the CSS for both to pretty it up a little. `border-color: grey; border-radius: 12px; padding: 10px;` – hokeybot May 16 '23 at 14:33