Skip to content

Positioning (Extended)

This component provides advanced positioning utility classes for precisely placing elements in Metro UI.

The position-ext component defines CSS classes for positioning elements in relation to their containers or other elements. These utilities are particularly useful for creating tooltips, dropdowns, popovers, and other UI components that need precise positioning.

These classes position elements outside their containers in specific directions, using CSS transforms. The naming follows compass directions (n = north, e = east, s = south, w = west).

ClassDescription
.put-nPositions element at the top center, outside the container
.put-nwPositions element at the top left corner, outside the container
.put-nePositions element at the top right corner, outside the container
.put-ePositions element at the middle right, outside the container
.put-enPositions element at the top right, outside the container
.put-esPositions element at the bottom right, outside the container
.put-sPositions element at the bottom left, inside the container
.put-swPositions element at the bottom center, inside the container
.put-sePositions element at the bottom right, inside the container
.put-wPositions element at the middle left, outside the container
.put-wnPositions element at the top left, outside the container
.put-wsPositions element at the bottom left, outside the container

These classes position elements at specific locations within their containers:

ClassDescription
.pos-top-leftPositions element at the top left corner of the container
.pos-top-centerPositions element at the top center of the container
.pos-top-rightPositions element at the top right corner of the container
.pos-bottom-leftPositions element at the bottom left corner of the container
.pos-bottom-centerPositions element at the bottom center of the container
.pos-bottom-rightPositions element at the bottom right corner of the container
.pos-left-centerPositions element at the middle left of the container
.pos-right-centerPositions element at the middle right of the container
.pos-centerPositions element at the center of the container
ClassDescription
.put-leftPositions element at the left edge of its container
.put-rightPositions element at the right edge of its container

All of the directional positioning classes (.put-*) have responsive variants that apply at specific breakpoints. The responsive variants follow the naming pattern .{class}-{breakpoint}.

For example:

  • .put-n-md - Applies north positioning on medium screens and above
  • .put-e-lg - Applies east positioning on large screens and above

Where {breakpoint} can be: xs, sm, md, lg, xl, xxl, xxxl

These positioning classes use a combination of:

  1. Absolute positioning (top, right, bottom, left properties)
  2. CSS transforms (translateX, translateY) for precise centering and positioning outside the container

For example, the .put-n class positions an element above its container by:

  • Setting top: 0 and left: 50% to position it at the top center
  • Using translateX(-50%) to center it horizontally
  • Using translateY(-100%) to move it completely above the container
<div class="position-relative">
Hover me
<div class="tooltip put-n">Tooltip appears above</div>
</div>
<div class="position-relative">
Hover me
<div class="tooltip put-e">Tooltip appears to the right</div>
</div>
<div class="dropdown position-relative">
<button class="dropdown-toggle">Dropdown</button>
<ul class="dropdown-menu put-s">
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
</ul>
</div>
<div class="modal-backdrop">
<div class="modal-dialog pos-center">
Modal content centered in the viewport
</div>
</div>
<!-- Dropdown appears below on small screens, to the right on medium screens and above -->
<div class="dropdown position-relative">
<button class="dropdown-toggle">Dropdown</button>
<ul class="dropdown-menu put-s put-e-md">
<li>Option 1</li>
<li>Option 2</li>
<li>Option 3</li>
</ul>
</div>
put-nw put-n put-ne
┌─────────────┐
put-wn │ │ put-en
│ │
put-w │ Container │ put-e
│ │
put-ws │ │ put-es
└─────────────┘
put-s put-sw put-se
  1. Parent Positioning: Ensure the parent element has position: relative for these positioning classes to work correctly.

  2. Overflow Handling: Be aware that elements positioned outside their containers may be clipped if the parent has overflow: hidden.

  3. Responsive Behavior: Use the responsive variants to adjust positioning based on screen size, especially for dropdowns and tooltips that might not fit on smaller screens.

  4. Z-Index: Elements positioned outside their containers may need a higher z-index to appear above other content.

  5. Combining with Other Utilities: These positioning classes work well with other Metro UI utilities like visibility classes (.d-none, .d-block) for creating interactive components.

  • The .put-* classes are particularly useful for creating tooltips, popovers, and dropdown menus.
  • The .pos-* classes are useful for positioning elements within containers, such as modal dialogs or notification badges.
  • For simple positioning needs, consider using the standard position.less utilities instead.