Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 7583

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 60k
Author
Asked: November 28, 20242024-11-28T05:10:09+00:00 2024-11-28T05:10:09+00:00

Helpful Page Layouts using Tailwind CSS

  • 60k

If you're here you're probably familiar with the CSS utility goodness that is Tailwind CSS. Using the default Tailwind base classes you can quickly knockout some very nice page layouts.

I've done oodles of layouts using Bootstrap, and I wanted to learn more about Tailwind so I thought some hands-on practice would be helpful. These example responsive layouts all make use of Tailwind's Flexbox classes.


2-Column Layout with Sidebar

Sidebar layout with Tailwind

Here's a super-basic 2-column page layout with Tailwind. It has a sidebar on the left, and a scrollable main content area on the right. There is also a footer that sticks to the bottom regardless of content height. Since I wanted to place a nav menu in the Sidebar, I made the Sidebar sticky so that it's always visible on the left as the page is scrolled vertically. The entire layout has a contained with and centered using container mx-auto

  <div class="container mx-auto">     <div class="flex flex-row flex-wrap py-4">         <aside class="w-full sm:w-1/3 md:w-1/4 px-2">             <div class="sticky top-0 p-4 w-full">                 <!-- navigation -->                 <ul class="flex flex-col overflow-hidden">                     ...                 </ul>             </div>         </aside>         <main role="main" class="w-full sm:w-2/3 md:w-3/4 pt-1 px-2">             <!-- content area -->         </main>     </div> </div> <footer class="mt-auto">     ... </footer>   
Enter fullscreen mode Exit fullscreen mode

Demo


Holy Grail Layout

Holy Grail layout with Tailwind

Perhaps the most famous layout for dotcom era Web designers, here's a Tailwind implementation of the 3-column “Holy Grail“. This layout is responsive so that the layout stacks vertically on smaller mobile screens. This fixed|fluid|fixed layout works well for pages that have a lot of content!

  <div class="w-full flex flex-col sm:flex-row flex-wrap sm:flex-nowrap py-4 flex-grow">     <!-- fixed-width -->     <div class="w-fixed w-full flex-shrink flex-grow-0 px-4">         <div class="sticky top-0 p-4 w-full h-full">             <!-- nav goes here -->         </div>     </div>     <main role="main" class="w-full flex-grow pt-1 px-3">         <!-- fluid-width: main content goes here -->     </main>     <div class="w-fixed w-full flex-shrink flex-grow-0 px-2">         <!-- fixed-width -->         <div class="flex sm:flex-col px-2">             <!-- sidebar goes here -->         </div>     </div> </div> <footer class="bg-black mt-auto">     ... </footer>   
Enter fullscreen mode Exit fullscreen mode

This layout also requires a little extra CSS to make the side columns fixed width…

  @media (min-width: 640px) {     .w-fixed {         flex: 0 1 230px;         min-width: 230px;     } }   
Enter fullscreen mode Exit fullscreen mode

The fixed widths are only applied above Tailwind's small breakpoint of 640px so that the layout stacks vertically on mobile devices.

Demo


Full-screen Background Image

Full-screen background layout with Tailwind

This is the very popular full-screen background image layout that works perfectly for landing pages. You can easily change the center overlay content to a sign-up for or call-to-action card.

This layout is responsive so that the centered content area is full-width on mobile, 50% width on small devices and 33% width on large devices.

  <div class="w-full p-4">     <main role="main" class="w-full flex flex-col h-screen content-center justify-center">         <div class="w-full sm:w-1/2 lg:w-1/3 bg-gray-50 rounded-xl m-auto">             <div class="bg-white rounded shadow px-4 pt-5 pb-4 sm:p-6 sm:pb-4">                 <!-- centered card -->             </div>         </div>     </main> </div>   
Enter fullscreen mode Exit fullscreen mode

Demo


Full-screen App Layout with Sidebar

Single page app layout with Tailwind

This single-page “app” style layout features a sidebar, main content area, and footer. This full-height layout is never more than viewport height. The content area scrolls independently as needed. For this example, we're using the Tailwind CSS utility framework. As part of it's default classes, Tailwind includes Flexbox classes which make this layout implementation simple!

Additionally, this layout is responsive. As screen width decreases down to 640px (the smallest Tailwind breakpoint), the layout stacks vertically. The sidebar orientation is flipped from vertical to horizontal (flex-col sm:flex-row), and the main content area fills the remaining height above the footer.

  <div class="w-full flex flex-col sm:flex-row flex-grow overflow-hidden">     <div class="sm:w-1/3 md:1/4 w-full flex-shrink flex-grow-0 p-4">         <div class="sticky top-0 p-4 w-full">             <ul class="flex sm:flex-col overflow-hidden content-center justify-between">                  <!-- nav goes here -->             </ul>         </div>     </div>     <main role="main" class="w-full h-full flex-grow p-3 overflow-auto">          <!-- content area -->     </main> </div> <footer class="mt-auto">     ... </footer>   
Enter fullscreen mode Exit fullscreen mode

Demo


Important! If you're going to use Tailwind, remember it's best to make it part of the JS build process so that you can choose the parts you need. The Tailwind CSS referenced in these examples is off CDN and a whopping 2.7MB 😲!

Thanks for reading, and I hope you can make use of these examples to kickstart your next Tailwind project! Play with Tailwind on Codeply

cssdesigntailwindcsswebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.