Logo hdtoledo
hdtoledo.dev
Módulos_del_Sistema
MÓDULO_TEÓRICO

Positioning, Layers, and Floating Modals

Positioning and Modals

Orchestrating Layers with relative, absolute, and fixed

In professional applications, confirmation dialogs, tooltips, and floating status tags are ubiquitous.

In Tailwind, controlling coordinate positioning and stacking hierarchy (z-index) is crisp and declarative.


1. Key Positioning Classes

  • relative: Establishes the coordinate reference frame.
  • absolute: Positions against the nearest relative ancestor (top-0, right-0, inset-0).
  • fixed: Pins directly to the browser Viewport (ideal for dialog overlays).
  • z-10, z-20, z-50: Elevation stacking hierarchy.

2. Crafting a Floating Glassmorphism Modal

html
<!-- Full Viewport Blurred Backdrop Overlay --> <div class="fixed inset-0 bg-slate-950/80 backdrop-blur-md flex items-center justify-center p-4 z-50"> <!-- Modal Dialog Container --> <div class="relative w-full max-w-lg bg-slate-900 border border-cyan-500/40 rounded-2xl p-6 shadow-2xl shadow-cyan-950/80"> <!-- Absolute Close Button --> <button class="absolute top-4 right-4 text-slate-400 hover:text-white p-2 rounded-lg hover:bg-slate-800 transition-colors"> ✕ </button> <!-- Modal Header --> <div class="flex items-center gap-3 mb-4"> <div class="w-10 h-10 rounded-xl bg-cyan-500/10 text-cyan-400 flex items-center justify-center font-bold text-lg"> ⚡ </div> <div> <h3 class="text-lg font-bold text-white">Deploy New Node</h3> <p class="text-xs text-slate-400">Select cluster region and computing tier</p> </div> </div> <!-- Modal Body --> <div class="space-y-4 my-6"> <div> <label class="block text-xs font-semibold text-slate-300 mb-1">Node Identifier</label> <input type="text" placeholder="NX-CLUSTER-09" class="w-full bg-slate-950 border border-slate-700 rounded-xl px-4 py-2.5 text-sm text-white focus:outline-none focus:border-cyan-400"> </div> <div> <label class="block text-xs font-semibold text-slate-300 mb-1">Server Cluster Region</label> <select class="w-full bg-slate-950 border border-slate-700 rounded-xl px-4 py-2.5 text-sm text-white focus:outline-none focus:border-cyan-400"> <option>US-East (N. Virginia)</option> <option>EU-Central (Frankfurt)</option> <option>AP-East (Tokyo)</option> </select> </div> </div> <!-- Modal Actions --> <div class="flex justify-end gap-3 pt-4 border-t border-slate-800"> <button class="px-4 py-2 rounded-xl text-xs font-bold text-slate-400 hover:text-white hover:bg-slate-800 transition-colors"> Cancel </button> <button class="px-5 py-2 rounded-xl text-xs font-bold bg-cyan-400 hover:bg-cyan-300 text-slate-950 shadow-md shadow-cyan-400/20 transition-all"> Initiate Deployment </button> </div> </div> </div>