width.Rd
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.
width(tag, size)
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.
|
Other design utilities:
active()
,
affix()
,
background()
,
border()
,
display()
,
float()
,
font()
,
height()
,
padding()
,
scroll()
,
shadow()
### Numeric `size` 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" )#> <div class="flex-column justify-content-between"> #> <div class="border border-black h-4 w-1"></div> #> <div class="border border-black h-4 w-2"></div> #> <div class="border border-black h-4 w-3"></div> #> <div class="border border-black h-4 w-4"></div> #> <div class="border border-black h-4 w-5"></div> #> <div class="border border-black h-4 w-6"></div> #> <div class="border border-black h-4 w-7"></div> #> <div class="border border-black h-4 w-8"></div> #> <div class="border border-black h-4 w-9"></div> #> <div class="border border-black h-4 w-10"></div> #> <div class="border border-black h-4 w-11"></div> #> <div class="border border-black h-4 w-12"></div> #> <div class="border border-black h-4 w-13"></div> #> <div class="border border-black h-4 w-14"></div> #> <div class="border border-black h-4 w-15"></div> #> <div class="border border-black h-4 w-16"></div> #> <div class="border border-black h-4 w-17"></div> #> <div class="border border-black h-4 w-18"></div> #> <div class="border border-black h-4 w-19"></div> #> <div class="border border-black h-4 w-20"></div> #> </div>### Fractional `size` 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") # <-#> <div class="mb-3 bg-red h-5 w-1/3"></div>