Functions for composing.
One query of a media rule. A media rule can have multiple queries. The CSS below contains 1 rule, with 2 queries.
@media print, screen and (monochrome) {
body {
color: black;
}
}The above rule roughly translates as: If the device is a printer or is a monoschrome screen, the body color is black.
In elm-css, queries are joined into rules using a special MediaQuery
returned by the or function.
Combines media query components into media queries.
(stylesheet << namespace "homepage")
[ media (and screen (Media.minWidth (px 300))
[ footer [ Css.maxWidth (px 300) ] ]
]The above code translates into the following css.
@media screen and (min-width: 300px) {
footer {
max-width: 300px;
}
}Combines media query components into media queries that are nested under selectors.
(stylesheet << namespace "homepage")
[ footer
[ withMedia [ screen, Media.minWidth (px 300), Media.maxWidth (px 800) ]
[ Css.maxWidth (px 300) ]
]@media screen and (min-width: 300px) and (max-width: 800px) {
footer {
max-width: 300px;
}
}Manually specify a media query using a List of strings.
mediaQuery [ "screen and (min-width: 320px)", "screen and (max-height: 400px)" ]
[ body [ fontSize (px 14)] ]The above code translates into the following css.
@media screen and (min-width: 320px), screen and (min-height: 400px) {
body {
font-size: 14px;
}
}Manually specify a media query that is nested under an element or class using a List of strings.
body
[ withMediaQuery [ "screen and (min-width: 320px)", "screen and (max-height: 400px)" ]
[ fontSize (px 14px) ]
]The above code translates into the following css.
@media screen and (min-width: 320px), screen and (min-height: 400px) {
body {
font-size: 14px;
}
}Media modifier to negate a query
media (not screen) [ body [ Css.color (hex "000000") ] ]Combine media queries, where matching either query should apply the following CSS properties.
media (or screen print) [ ... ]The rule above will apply to either screens or printers.
Combine media queries, where matching either query should apply the following CSS properties.
media (and screen print) [ ... ]The rule above will apply to both screens and printers.
Media type for all devices. This is assumed by default if no other media type is specified.
Media type for any device not matched by print or speech.
media (and screen (maxWidth (px 600)) [ Css.class mobileNav display none ]Media type for printers
media print [ a [ color (hex 000000), textDecoration none ] ]Media type for screenreaders and similar devices that read out a page
media (not speech) [ Css.class screenReaderOnly [ display none ] ]Media feature min-width
Queries the width of the output device.
media (Media.minWidth (px 600)) [ Css.class Container [ Css.maxWidth (px 500) ] ]Media feature width
media (Media.width (px 200)) [ ... ]Media feature max-width
media (Media.maxWidth (px 800)) [ Css.class MobileNav [ display none] ]Media feature min-height
media (Media.minHeight(px 400)) [ Css.class TopBanner [ display block] ]Media feature max-height
media (Media.maxHeight(px 399)) [ Css.class TopBanner [ display none] ]Create a ratio.
--a ratio of 4/3
ratio 4 3Media feature min-aspect-ratio
media (minAspectRatio (ratio 1 1)) [ ... ]Media feature aspect-ratio
media (aspectRatio (ratio 16 10)) [ ... ]Media feature max-aspect-ratio
media (maxAspectRatio (ratio 16 9)) [ ... ]Media feature orientation.
Accepts portrait or landscape.
Display Resolution. https://www.w3.org/TR/css3-values/#resolution-value
dpi: Dots per inch. https://www.w3.org/TR/css3-values/#resolution-value
dpi 166dpcm: Dots per centimeter. https://www.w3.org/TR/css3-values/#resolution-value
dpcm 65dppx: Dots per pixel. https://www.w3.org/TR/css3-values/#resolution-value
dppx 1.5Media feature min-resolution.
Describes the resolution of the output device.
media (minResolution (dpi 600)) [ Css.class HiResImg [ display block ] ]Media feature resolution
Describes the resolution of the output device.
media (resolution (dppx 2)) [ img [ width (pct 50) ] ]Media feature max-resolution
Describes the resolution of the output device.
media (maxResolution (dpcm 65)) [ Css.class HiResImg [ display none ] ]Media feature scan.
Queries scanning process of the device. Accepts innterlace (some TVs) or progressive (most things).
CSS value progressive
Media feature scan.
Queries scanning process of the device. Accepts innterlace (some TVs) or progressive (most things).
Media feature update
The update frequency of the device. Accepts none, slow, or fast
CSS value optional-paged
Media feature overflow-block
Describes the behavior of the device when content overflows the initial containing block in the block axis.
Media feature overflow-inline.
Describes the behavior of the device when content overflows the initial containing block in the inline axis.
Get a bumber of bits
bits 8Media Feature min-nncolor
Queries the user agent's bits per color channel
media (screen (minColor (bits 256))) [ a [ Css.color (hex "D9534F") ] ]Media feature max-color
Queries the user agent's bits per color channel
media (and screen (maxColor (bits 8))) [ a [ Css.color (hex "FF0000") ] ]Media Feature min-monochrome
Media feature monochrome
media [ monochrome ] [ body [Css.color (hex "000000")] ]Media feature max-monochrome
Media Feature min-color-index
Queries the number of colors in the user agent's color lookup table.
media (and screen (minColorIndex (int 16777216))) [ a [ Css.color (hex "D9534F")] ]Media feature color-index
Queries the number of colors in the user agent's color lookup table.
media (and screen (colorIndex (int 16777216))) [ a [ Css.color (hex "D9534F") ] ]Media feature max-color-index.
Queries the number of colors in the user agent's color lookup table.
media (and screen (maxColorIndex (int 256))) [ a [ Css.color (hex "FF0000")] ]Media feature color-gamut.
Describes the approximate range of colors supported by the user agent and device.
media (and screen (colorGamut rec2020)) [ Css.class HiColorImg [ display block ] ]Media feature pointer
Queries the presence and accuracy of a pointing device, such as a mouse, touchscreen, or Wii remote.
Reflects the capabilities of the primary input mechanism.
Accepts none, fine, and coarse.
media (Media.pointer coarse) [ a [ display block, Css.height (px 24) ] ]Media feature any-pointer
Queries the presence and accuracy of a pointing device, such as a mouse, touchscreen, or Wii remote.
Reflects the capabilities of the most capable input mechanism.
Accepts none, fine, and coarse.
media (anyPointer coarse) [ a [ display block, Css.height (px 24) ] ]The value hover.
Named canHover to avoid conflict with the media feature of the same name
Media feature hover.
Queries the if the user agent's primary input mechanism has the ability to hover over elements.
Accepts none or canHover.
media (Media.hover canHover) [ a [ Css.hover [ textDecoration underline] ] ]Media feature any-hover
Queries the if any of user agent's input mechanisms have the ability to hover over elements
Accepts none or canHover.
media (anyHover canHover) [ a [ Css.hover [ textDecoration underline] ] ]CSS value initial-only.