Learn R Programming

yonder (version 0.1.0)

width: Tag element width

Description

Utility function to change a tag element's width. Widths are specified relative to the font size of page (browser default is 16px), relative to their parent element (i.e. 1/2 the width of their parent), or relative to the element's content.

Usage

width(tag, size)

Arguments

tag

A tag element.

size

A character string or number specifying the width of the tag element. Possible values:

An integer between 1 and 20, in which case the width of the element is relative to the font size of the page.

"1/2", "1/3", "2/3", "1/4", "3/4", "1/5", "2/5", "3/5", "4/5", or "full", in which case the element's width is a percentage of its parent's width. The height of the parent element must be specified for percentage widths to work. Percentages do not account for margins or padding and may cause an element to extend beyond its parent.

"auto", in which case the element's width is determined by the browser. The browser will take into account the width, padding, margins, and border of the tag element's parent to keep the element from extending beyond its parent.

See Also

Other design: active, affix, background, border, display, float, font, height, padding, scroll, shadow

Examples

Run this code
# NOT RUN {
### Numeric values

# When specifying a numeric value the width of the element is relative to the
# default font size of the page.

div(
  lapply(
    1:20,
    width,
    tag = div() %>%
      border("black") %>%
      height(4)
  )
) %>%
  flex(
    direction = "column",
    justify = "between"
  )

### Fractional values

# When specifying width as a fraction the element's width is a percentage of
# its parent's width.

div() %>%
  margin(b = 3) %>%
  background("red") %>%
  height(5) %>%
  width("1/3")  # <-

# }

Run the code above in your browser using DataLab