Published on

6 Incredibly Easy Ways To Create A E Commerce Homepage Layout With Tailwind CSS Better While Spending Less

Tags
E commerce Homepage layout

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of E commerce Homepage layout ui component

Tailwind css e commerce homepage layout by jamsheed ali

Why use Tailwind CSS to create a E commerce Homepage layout ui component?

  • It can make the building process of E commerce Homepage layout ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in E commerce Homepage layout component file.

The preview of E commerce Homepage layout ui component

Free download of the E commerce Homepage layout's source code

The source code of E commerce Homepage layout ui component

<div class="bg-black">
  <div class="flex relative text-center">
  <h1 class="text-3xl tracking-wider text-white text-sha uppercase font-bold p-4 self-center z-10 content-center absolute text-center w-full md:text-4xl">Welcome to Lightning deals</h1>
  <img class="w-full object-cover h-72 block mx-auto  sm:block sm:w-full" 
  src="https://images.unsplash.com/photo-1505934333218-8fe21ff87e69?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80"
   alt="Banner" width="1920" height="288" />
  </div>
  </div>
  
  <div class="p-5 mx-auto max-w-screen-xl">
  <h2 class="font-bold uppercase text-xl pb-4">Best sellers</h2>
  
  <div class="grid grid-flow-row-dense grid-cols-2 gap-3 justify-between sm:grid-cols-3 md:grid-cols-4">

  <div>
  <img class="border border-yellow-700 mb-1 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1594760467096-03761ecedde4?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MzE2fHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
   <h2 class="pt-2 m-0 leading-4 font-semibold">Indoor light 2021 USA</h2>
   <p>$210</p>
   <p class="text-green-500 italic font-medium">In Stock</p>
    </div>
    <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1592009104079-88046bd5a09a?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MzQwfHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Indoor light 2021 USA</h2>
   <p>$210</p>
   <p class="text-green-500 italic font-medium">In Stock</p>
    </div>
    <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1562635254-c14536b57bcb?ixid=MnwxMjA3fDB8MHxzZWFyY2h8NDd8fGxpZ2h0aW5nfGVufDB8MnwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Indoor light 2021 USA</h2>
   <p>$210</p>
   <p class="text-green-500 italic font-medium">In Stock</p>
    </div>
   <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1595389397394-01fed35d24bc?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTAwfHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Outdoor light 2021 USA</h2>
   <p>$210</p>
     <p class="text-red-500 italic font-medium">Out of Stock</p>
    </div>
  <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1577430605074-47eb89cc8969?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTExfHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Indoor light 2020 USA</h2>
   <p>$210</p>
   <p class="text-green-500 italic font-medium">In Stock</p>
    </div>
  <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1565475266382-7870244b60f9?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MjYzfHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Indoor light 2021 USA</h2>
   <p>$210</p>
   <p class="text-green-500 italic font-medium">In Stock</p>
    </div>
  <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1588707698376-559b54b41846?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MjgyfHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Outdoor light 2020 USA</h2>
   <p>$210</p>
   <p class="text-red-500 italic font-medium">Out of Stock</p>
    </div>
  <div class="">
  <img class="border border-yellow-700 border-solid w-full hover:border-yellow-500" alt="Best seller" 
  src="https://images.unsplash.com/photo-1533637268824-0da337d92744?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MzAyfHxsaWdodGluZ3xlbnwwfDJ8MHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" loading="lazy" />
  <h2 class="pt-2 m-0 leading-4 font-semibold">Outdoor light 2021 USA</h2>
   <p>$210</p>
   <p class="text-green-500 italic font-medium">In Stock</p>
    </div>
  
  </div>
  </div>

  <div class="bg-gray-200">
    <section class="py-5 mx-auto max-w-screen-xl  sm:flex flex-grow-0 sm:p-5">
    <article class="flex-col justify-center inline-flex self-stretch  p-6">
      <h2 class="uppercase font-semibold text-xl">Design</h2>
      <strong class="text-lg pb-2 font-normal font-sans sm:text-2xl">Our 30 Year Journey</strong>
      <p class="text-sm pb-4">Join us as we revisit our roots, tracing the path from bright idea to industry disruptors with a plan to fight climate change while creating beautiful things. </p>
      <button class="font-semibold uppercase border-black border p-3 max-w-max hover:bg-gray-600 hover:text-white">Join us</button>
    </article>
    <figure>
    <img 
    src="https://images.unsplash.com/photo-1606170033648-5d55a3edf314?ixid=MnwxMjA3fDB8MHxzZWFyY2h8MjR8fGxpZ2h0c3xlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60" 
    alt="Banner" looding="lazy" />
    </figure>
    </section>
  </div>

How to create a E commerce Homepage layout with Tailwind CSS?

Install tailwind css of verion 2.1.4

Use the script html tag to import the script of Tailwind CSS of the version 2.1.4

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to create a E commerce Homepage layout component

  • bg-black
  • flex
  • relative
  • text-center
  • text-3xl
  • text-white
  • text-sha
  • p-4
  • z-10
  • absolute
  • w-full
  • md:text-4xl
  • h-72
  • block
  • mx-auto
  • sm:block
  • sm:w-full
  • p-5
  • max-w-screen-xl
  • text-xl
  • pb-4
  • grid
  • grid-flow-row-dense
  • grid-cols-2
  • gap-3
  • sm:grid-cols-3
  • md:grid-cols-4
  • border-yellow-700
  • mb-1
  • border-solid
  • hover:border-yellow-500
  • pt-2
  • m-0
  • text-green-500
  • text-red-500
  • bg-gray-200
  • py-5
  • sm:flex
  • flex-grow-0
  • sm:p-5
  • flex-col
  • inline-flex
  • p-6
  • text-lg
  • pb-2
  • sm:text-2xl
  • text-sm
  • border-black
  • p-3
  • max-w-max
  • hover:bg-gray-600
  • hover:text-white

52 steps to create a E commerce Homepage layout component with Tailwind CSS

  1. Control the background color of an element to black using the bg-black utilities.

  2. Use flex to create a block-level flex container.

  3. Use relative to position an element according to the normal flow of the document.

  4. Control the text color of an element to center using the text-center utilities.

  5. Control the text color of an element to 3xl using the text-3xl utilities.

  6. Control the text color of an element to white using the text-white utilities.

  7. Control the text color of an element to sha using the text-sha utilities.

  8. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  9. Control the stack order (or three-dimensional positioning) of an element to 10 in Tailwind, regardless of order it has been displayed, using the z-10 utilities.

  10. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  11. Use w-full to set an element to a 100% based width.

  12. Control the text color of an element to 4xl at only medium screen sizes using the md:text-4xl utilities.

  13. Use h-72 to set an element to a fixed height(18rem).

  14. Use inline utilities to put the element on its own line and fill its parent.

  15. Control the horizontal margin of an element to auto using the mx-auto utilities.

  16. Use inline utilities to put the element on its own line and fill its parent at only small screen sizes.

  17. Use w-full to set an element to a 100% based width at only small screen sizes.

  18. Control the padding on all sides of an element to 1.25rem using the p-5 utilities.

  19. Set the maximum width/height of an element using the max-w-screen-xl utilities.

  20. Control the text color of an element to xl using the text-xl utilities.

  21. Control the padding on bottom side of an element to 1rem using the pb-4 utilities.

  22. Use grid to create a grid container.

  23. Use grid to create a grid container.

  24. Use grid to create a grid container.

  25. To specify the width between columns, you can use the gap-3 utilities.

  26. Use grid to create a grid container at only small screen sizes.

  27. Use grid to create a grid container at only medium screen sizes.

  28. Control the border color of an element to yellow-700 using the border-yellow-700 utilities.

  29. Control the margin on bottom side of an element to 0.25rem using the mb-1 utilities.

  30. Control the border color of an element to solid using the border-solid utilities.

  31. Control the border color of an element to yellow-500 using the hover:border-yellow-500 utilities on hover.

  32. Control the padding on top side of an element to 0.5rem using the pt-2 utilities.

  33. Control the margin on all sides of an element to 0rem using the m-0 utilities.

  34. Control the text color of an element to green-500 using the text-green-500 utilities.

  35. Control the text color of an element to red-500 using the text-red-500 utilities.

  36. Control the background color of an element to gray-200 using the bg-gray-200 utilities.

  37. Control the vertical padding of an element to 1.25rem using the py-5 utilities.

  38. Use flex to create a block-level flex container at only small screen sizes.

  39. Use flex to create a block-level flex container.

  40. Control the padding on all sides of an element to 1.25rem at only small screen sizes using the sm:p-5 utilities.

  41. Use flex to create a block-level flex container.

  42. Use inline-flex to create an inline flex container that flows with text.

  43. Control the padding on all sides of an element to 1.5rem using the p-6 utilities.

  44. Control the text color of an element to lg using the text-lg utilities.

  45. Control the padding on bottom side of an element to 0.5rem using the pb-2 utilities.

  46. Control the text color of an element to 2xl at only small screen sizes using the sm:text-2xl utilities.

  47. Control the text color of an element to sm using the text-sm utilities.

  48. Control the border color of an element to black using the border-black utilities.

  49. Control the padding on all sides of an element to 0.75rem using the p-3 utilities.

  50. Set the maximum width/height of an element using the max-w-max utilities.

  51. Control the background color of an element to gray-600 using the hover:bg-gray-600 utilities on hover.

  52. Control the text color of an element to white on hover using the hover:text-white utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to create a E commerce Homepage layout components, learn and follow along to implement your own components.