Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

CSS in markdown header

Started by Tanguy Chabrol 9 years ago · 8 replies · 1458 views
9 years ago

Hi,

I would like to switch two modular folders in my markdown header depending on the screen size of the user.
I was wondering if there was any way to embed CSS directly into a markdown header, like media queries.

Not sure if I'm clear, basically I would like to have something like :

MARKDOWN
> ---
> title: Home
> content:
> items: '@self.modular'
> order:
>     by: default
>     dir: asc
>     custom:
>         - _showcase
>         - _highlights
>         - _news
>         - _callout
>         - _bottom
> @media only all and (max-width: 49.987em) {
> content:
> items: '@self.modular'
> order:
>     by: default
>     dir: asc
>     custom:
>         - _showcase
>         - _highlights
>         - _callout
>         - _news
>         - _bottom
> }
> menu: Home
> visible: false
> onpage_menu: false
> ---
last edited 09/20/17 by Tanguy Chabrol
9 years ago

My 1st call would be to handle this via css positioning, did you thought about it?

9 years ago

Hi,

Thank you for your answer,

No, I'm quite new to web technologies, and I'm not sure to understand what CSS positioning is.
The only solution I came up to so far was to create two modular folder for the two positions. These two modular would be identical except that they are displayed depending on the screen size.

9 years ago

If you wrap your module contents in some CSS .class, you will be able to display it in desired position.

9 years ago

Ok, I'll try this. So about my initial question, you cannot, in any way, put some css in markdown ?

9 years ago

You can put CSS in Markdown, but I do not know of any way to put it in frontmatter (header)

9 years ago

okay, on first reading, I seem to not have understood your requirements completely.

What @MakaryGo said is your correct starting point.

This is solveable in css completely and should be done there. Something like:

@media only all and (max-width: 49.987em) {
/ use flexbox and reorder the things./
}

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago