Nick
Nick

Reputation: 859

r markdown: Assign image (or other element) an id or class as a CSS selector

I'm currently trying to automate statistical report generation with r Markdown. I've managed to tweak the CSS to my liking for the most part, but now I want a logo in the top left hand corner of the header.

My plan was to just absolutely position it and adjust the header around it, the only problem is there's no unique class or id for it to be selected by in the CSS file, so if I want more than one image (which in some I will) they'll all get absolutely positioned in the same place.


Another thing I've noticed is that the page width is defined within the body of the HTML output, meaning it's further down in the CSS cascade and so if I try to set it it gets overwritten later on. Does anyone have any idea how to circumvent this?

Sorry if two questions in one is cheating, they just seem somewhat related.

Thank you.

Upvotes: 3

Views: 727

Answers (1)

Nick
Nick

Reputation: 859

In answer to the first half of my question, I ended up printing the following:

``` {r logo, results="asis", echo = FALSE}

print("<img src='*URL*' id='logo' />")

```

Then set the visibility of the <p> tag that outputs the R console text to hidden, which I then over ride within the #logo CSS.

Still not found a way to over-ride the max-width however.

Upvotes: 1

Related Questions