The affix utility function applies Bootstrap classes to fix elements to the top or bottom of a page. Use "sticky" to cause an element to fix to the top of a page after the element is scrolled past. Important, the IE11 and Edge browsers do not support the sticky behavior.

affix(tag, position)

Arguments

tag

A tag element.

position

One of "top", "bottom", or "sticky" specifying the fixed behavior of an element.

See also

Other design utilities: active(), background(), border(), display(), float(), font(), height(), padding(), scroll(), shadow(), width()

Examples

### Affix an element div( span("I'm up here!") %>% padding(left = 3, right = 3) %>% background("teal") ) %>% display("flex") %>% flex(justify = "center") %>% affix("top")
#> <div class="d-flex justify-content-center fixed-top"> #> <span class="pr-3 pl-3 bg-teal">I'm up here!</span> #> </div>