Absolute Positioning
The place-* classes can be used to achieve absolute element positioning, and are ideal for positioning elements within layouts. There are 9 placing classes as described in the following table.
Absolute PositioningThe place-* classes are best used within a container. WebUI provides a set of container classes that are all relatively positioned, and therefore serve as a positioning context when using the place-* classes.
The following example uses a panel container as the positioning context.
Example<div class="panel background-accent-1-light height-xl text-sm"> <div class="height-md width-md accent-1 place-top-center"> <span class="place-middle-center">place-top-center</span> </div> <div class="height-md width-md accent-1 place-middle-left"> <span class="place-middle-center">place-middle-left</span> </div> <div class="height-md width-md accent-1 place-middle-center"> <span class="place-middle-center">place-middle-center</span> </div> <div class="height-md width-md accent-1 place-middle-right"> <span class="place-middle-center">place-middle-right</span> </div> <div class="height-md width-md accent-1 place-bottom-center"> <span class="place-middle-center">place-bottom-center</span> </div> </div>
Fixed Positioning
The dock-* classes can be used to achieve fixed element positioning, and are ideal for positioning headers, footers, and menus. There are 9 docking classes as described in the following table.
Absolute PositioningA WebUI container is not required when using the dock-* classes for absolute positioning, since a dock-* class will take the element out of the normal content flow.
<div class="form-row text-bold text-sm"> <div class="form-col-20 background-accent-1-light gap-horizontal-md"> <button type="button" class="button-sm button-accent-1" id="toggleFixedFooterPanel"> Toggle Fixed Footer Panel </button> </div> <div class="panel dock-bottom-center hidden height-sm width-full accent-1-light" id="fixedFooterPanel"> <span class="place-middle-center">Fixed Footer Panal</span> </div> </div>
ui("#toggleFixedFooterPanel").click(function() { ui("#fixedFooterPanel").toggle(); });
Custom Positioning
WebUI includes a number of utility classes that can be used to assist with element positioning, as listed in the following table. These classes can be used on their own or in combination with the place-* or dock-* classes.<div class="panel background-accent-1-light height-lg-xl text-sm"> <div class="place-top-right top-xs right-sm pad-sm accent-1"> <div>place-top-right top-xs right-sm</div> </div> <div class="place-middle-left left-sm pad-sm accent-1"> <div>place-middle-left left-sm</div> </div> </div>
Snap PositioningJavaScript required
If more granular positioning is required, then WebUI provides the snap positioning JavaScript utility function that can be used to accurately position elements relative to any other element.
Example<div class="container height-lg"> <div class="width-lg-xl height-md-lg border-sm border-color-muted" id="containerSnapPosition"> <div class="diamond-flat-shape" data-size="5rem" data-rotation="0" data-class="custom-image" id="shapeSnapPosition"></div> </div> </div>
ui("#shapeSnapPosition").snapPosition("#containerSnapPosition", [0, -0.6], "rem");