search results:

    • Standard
    • React
    Pricing Learn Community
    • + D
    • Light
    • Dark
    • System
    logo TW Elements
    • Getting started
      • Quick start
      • Tutorials
      • Design system
      • Local installation
      • Optimization
      • Dark mode
      • Theming
      • Changelog
      • Migrating to v2
      • Internationalization guide
      • Class customization
      • Icons Integration
    • CommercialNew
      • Pricing
      • License
      • Installation
      • Git & repository
      • Premium Support
    • Integrations
      • Angular
      • ASP.NET
      • Django
      • Express
      • Laravel
      • Next
      • Nuxt
      • Qwik
      • React
      • Remix
      • Solid
      • Svelte
      • SvelteKit
      • Vue
    • Content & styles
      • Animations
      • Animations Extended
      • Colors
      • Dividers
      • Figures
      • Headings
      • Hover effects
      • Icons
      • Images
      • Mask
      • Shadows
      • Typography
    • Navigation
      • Breadcrumbs
      • Footer
      • Headers
      • Mega menu
      • Navbar
      • Offcanvas
      • Pagination
      • Pills
      • Scrollspy
      • Sidenav
      • Tabs
    • Components
      • Accordion
      • Alerts
      • Avatar
      • Badges
      • Button group
      • Buttons
      • Cards
      • Carousel
      • Chips
      • Collapse
      • Dropdown
      • Gallery
      • Jumbotron
      • Lightbox
      • Link
      • List group
      • Modal
      • Notifications
      • Paragraphs
      • Placeholders
      • Popconfirm
      • Popover
      • Progress
      • Rating
      • Scroll back to top button
      • Social buttons
      • Spinners
      • Stepper
      • Testimonials
      • Timeline
      • Toast
      • Tooltip
      • Video
      • Video carousel
    • Forms
      • Autocomplete
      • Checkbox
      • Datepicker
      • Datetimepicker
      • File input
      • Form templates
      • Input Group
      • Inputs
      • Login form
      • Multi range slider
      • Radio
      • Range
      • Registration form
      • Search
      • Select
      • Switch
      • Textarea
      • Timepicker
      • Validation
    • Data
      • Charts
      • Charts advanced
      • Datatables
      • Tables
    • Methods
      • Clipboard
      • Infinite scroll
      • Lazy loading
      • Loading management
      • Ripple
      • Scrollbar
      • Smooth scroll
      • Sticky
      • Touch
    • Design Blocks
      • Admin Charts
      • Admin Complex
      • Admin Forms
      • Admin Maps
      • Admin Navigation
      • Admin tables
      • Banners
      • Contact
      • Content
      • CTA
      • FAQ
      • Features
      • Headers
      • Hero / Intro sections
      • Logo clouds
      • Mega menu
      • News
      • Newsletter
      • Pricing
      • Projects
      • Stats
      • Stats admin
      • Team
      • Testimonials
    • Tools
      • Button generator
      • Card generator
      • Flexbox generator
      • Footer generator
      • Form builder
      • Grid generator
      • Icon generator
      • Instagram Filters generator
      • Logo generator
      • Table generator
      • Typography generator
    • Coming Soon
      • Angular
      • Builder
      • Templates
      • Vue
    • Resources
      • Playground
      • YouTube Channel
      • Private FB Group
      • Newsletter
      • UI Design course New
      • UI / UX tips
    • Overview
    • CARDS

    Position

    Tailwind CSS Position

    Use responsive position utilities with TW elements. A tutorial on how to control the position of elements.


    Statically positioning elements

    Use .static class to position an element according to the normal flow of the document.

    Any offsets will be ignored and the element will not act as a position reference for absolutely positioned children.

    Static parent

    Absolute child

    • HTML
            
                
            <div class="... static">
              <p>Static parent</p>
              <div class="... absolute bottom-0 left-0">
                <p>Absolute child</p>
              </div>
            </div>
            
            
        

    Relatively positioning elements

    Use .relative class that allows the element to be positioned relative to its normal position in the document flow.

    Any offsets are calculated relative to the element’s normal position and the element will act as a position reference for absolutely positioned children.

    Relative parent

    Absolute child

    • HTML
            
                
            <div class="... relative">
              <p>Relative parent</p>
              <div class="... absolute bottom-0 left-0 ">
                <p>Absolute child</p>
              </div>
            </div>
            
            
        

    Absolutely positioning elements

    In order to position an element outside of the regular flow of a document and have its neighboring elements behave as if the element is not present, one can make use of .absolute class.

    With static positioning

    Relative parent

    Static parent

    Static child

    Static sibling

    With absolute positioning

    Relative parent

    Static parent

    Absolute child

    Static sibling

    • HTML
            
                
            <div class="... static">
              <!-- Static parent -->
              <div class="... static"><p>Static child</p></div>
              <div class="... inline-block"><p>Static sibling</p></div>
              <!-- Static parent -->
              <div class="... absolute"><p>Absolute child</p></div>
              <div class="... inline-block"><p>Static sibling</p></div>
            </div>
            
            
        

    Fixed positioning elements

    To create an element with a fixed position in Tailwind, you can use the .fixed class. The fixed class positions the element relative to the viewport, which means it will stay in the same position even if the user scrolls the page.

    Contacts

    Corey Anderson

    Ray Flint

    John Smith

    Maria Samantha

    Mindy Albrect

    Lisa Cudrow

    Emily Williams

    • HTML
            
                
            <div class="relative">
              <div class="fixed left-0 right-0 top-0">Contacts</div>
              <div>
                <div>
                  <img src="..." />
                  <strong>Ray Flint</strong>
                </div>
                <div>
                  <img src="..." />
                  <strong>Emily Williams</strong>
                </div>
                <!-- ... -->
              </div>
            </div>
            
            
        

    Sticky positioning elements

    Use .sticky class to position an element as relative until it crosses a specified threshold, then treat it as fixed until its parent is off screen.

    Any offsets are calculated relative to the element’s normal position and the element will act as a position reference for absolutely positioned children.

    A

    Abigail Davis

    Alexander Lee

    Amelia Collins

    Andrew Carter

    B

    Benjamin Hughes

    Bradley Wood

    Brianna White

    Brittany Campbell

    C

    Caleb Adams

    Catherine James

    Charlotte Gray

    Corey Bailey

    • HTML
            
                
            <div>
              <div>
                <div class="... sticky top-0">A</div>
                <div>
                  <div>
                    <img src="..." />
                    <p>Abigail Davis</p>
                  </div>
                  <!-- ... -->
                  <div>
                    <img src="..." />
                    <p>Andrew Carter</p>
                  </div>
                </div>
              </div>
              <div>
                <div class="sticky top-0">B</div>
                <div>
                  <div>
                    <img src="..." />
                    <p>Benjamin Hughes</p>
                  </div>
                  <!-- ... -->
                </div>
              </div>
              <!-- ... -->
            </div>
            
            
        

    Related resources

    Position sticky Position fixed Position absolute Position static Position relative Float right Display Flex Display block Visibility Background position Overflow Overflow hidden Sticky Breakpoints Z-index Spacing

    If you are looking for more advanced options, try position from MDBootstrap.

    • Statically positioning elements
    • Relatively positioning elements
    • Absolutely positioning elements
    • Fixed positioning elements
    • Sticky positioning elements
    • Related resources
    Get useful tips & free resources directly to your inbox along with exclusive subscriber-only content.
    Join our mailing list now
    © 2024 Copyright: MDBootstrap.com

    Access restricted

    To view this section you must have an active PRO account

    Log in to your account or purchase an TWE subscription if you don't have one.

    Buy TWE PRO