mx-2: Tailwind CSS Margin class

The mx-2 class adds a margin of 0.5rem (8px) to the left and right sides of an element


mx-2 (Horizontal Margin 2)

The mx-2 class adds a margin of 0.5rem (8px) to the left and right sides of an element.

Example Usage

html
<div class="mx-2 bg-yellow-500 text-black">
Horizontal margin of 0.5rem
</div>

Preview

Mx-2

How to Use

Add the mx-2 class directly to your HTML element:

html
<div class="mx-2">
<!-- Your content here -->
</div>

Responsive Usage

Use Tailwind's responsive prefixes to apply mx-2 at specific breakpoints:

html
<div class="sm:mx-2 md:mx-2 lg:mx-2">
Responsive element
</div>
  • sm:mx-2 — applies from 640px and up
  • md:mx-2 — applies from 768px and up
  • lg:mx-2 — applies from 1024px and up

Customization

You can extend or override this utility in your tailwind.config.js. See the Tailwind CSS documentation for details on customizing your theme.

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates