Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cssContainerQuery constructor option #377

Merged
merged 3 commits into from
Oct 15, 2023
Merged

cssContainerQuery constructor option #377

merged 3 commits into from
Oct 15, 2023

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Oct 15, 2023

Added cssContainerQuery constructor option to support CSS container queries, @container at-rule and cqw cqh cqi cqb cqmin cqmax units for child elements of the slide element section.

new Marpit({ cssContainerQuery: true })
div.marpit > :where(section) {
  container-type: size;
}

By enabling this option, Marpit will become able to use features that related to CSS container queries, within both of the theme and the tweaked styles by Markdown.

/* Container query */
@container (width > 1000px) {
  h1 {
    color: red;
  }
}

h1 {
  font-size: 5cqw; /* Container-based unit */
}

If passed string or array of strings to cssContainerQuery, Marpit will set the container name to identify the slide element in @container at-rule.

new Marpit({ cssContainerQuery: 'marpit-slide' })
div.marpit > :where(section) {
  container-type: size;
  container-name: marpit-slide;
}

If the container-size and container-name CSS declaration were already declared to section element through the theme CSS or tweaked styles, Marpit prefers them than the injected style by the constructor option. The injected style has low CSS specificity by using :where selector.

For keeping backward compatibillity, cssContainerQuery constructor option is false by default in Marpit v2. In downstream libraries and tools of Marp ecosystem, we may enable this option by default.

Resolves #355.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS container query support (@container)
1 participant