CSS 转 Tailwind
将 CSS 属性转换为 TailwindCSS 类名,支持常见属性映射
常用 CSS 属性映射表
| CSS 属性 | Tailwind 类名 |
|---|---|
| display: block | block |
| display: inline-block | inline-block |
| display: inline | inline |
| display: flex | flex |
| display: inline-flex | inline-flex |
| display: grid | grid |
| display: inline-grid | inline-grid |
| display: hidden | hidden |
| flex-direction: row | flex-row |
| flex-direction: column | flex-col |
| flex-direction: row-reverse | flex-row-reverse |
| flex-direction: column-reverse | flex-col-reverse |
| justify-content: flex-start | justify-start |
| justify-content: center | justify-center |
| justify-content: flex-end | justify-end |
| justify-content: space-between | justify-between |
| justify-content: space-around | justify-around |
| justify-content: space-evenly | justify-evenly |
| align-items: flex-start | items-start |
| align-items: center | items-center |
| align-items: flex-end | items-end |
| align-items: stretch | items-stretch |
| flex-wrap: wrap | flex-wrap |
| flex-wrap: nowrap | flex-nowrap |
| flex: 1 | flex-1 |
| flex: auto | flex-auto |
| flex: none | flex-none |
| flex-grow: 1 | grow |
| flex-grow: 0 | grow-0 |
| flex-shrink: 0 | shrink-0 |
| flex-shrink: 1 | shrink |
| padding: 4px | p-1 |
| padding: 8px | p-2 |
| padding: 12px | p-3 |
| padding: 16px | p-4 |
| padding: 24px | p-6 |
| padding: 32px | p-8 |
| padding: 48px | p-12 |
| padding-top: 8px | pt-2 |
| padding-bottom: 8px | pb-2 |
| padding-left: 8px | pl-2 |
| padding-right: 8px | pr-2 |
| margin: 4px | m-1 |
| margin: 8px | m-2 |
| margin: 16px | m-4 |
| margin: auto | m-auto |
| margin-top: 8px | mt-2 |
| margin-bottom: 8px | mb-2 |
| margin-left: 8px | ml-2 |
| margin-right: 8px | mr-2 |
| font-size: 12px | text-xs |
| font-size: 14px | text-sm |
| font-size: 16px | text-base |
| font-size: 18px | text-lg |
| font-size: 20px | text-xl |
| font-size: 24px | text-2xl |
| font-size: 30px | text-3xl |
| font-size: 36px | text-4xl |
| font-weight: 400 | font-normal |
| font-weight: 700 | font-bold |
| font-weight: 300 | font-light |
| font-weight: 500 | font-medium |
| font-weight: 600 | font-semibold |
| text-align: left | text-left |
| text-align: center | text-center |
| text-align: right | text-right |
| line-height: 1 | leading-none |
| line-height: 1.25 | leading-tight |
| line-height: 1.5 | leading-normal |
| line-height: 2 | leading-loose |
| color: #000000 | text-black |
| color: #ffffff | text-white |
| color: #ef4444 | text-red-500 |
| color: #3b82f6 | text-blue-500 |
| color: #10b981 | text-emerald-500 |
| color: #6b7280 | text-gray-500 |
| color: #111827 | text-gray-900 |
| background-color: #000000 | bg-black |
| background-color: #ffffff | bg-white |
| background-color: transparent | bg-transparent |
| background-color: #3b82f6 | bg-blue-500 |
| background-color: #ef4444 | bg-red-500 |
| background-color: #f3f4f6 | bg-gray-100 |
| border: 1px solid #e5e7eb | border border-gray-200 |
| border: 2px solid #000 | border-2 border-black |
| border-radius: 4px | rounded |
| border-radius: 8px | rounded-lg |
| border-radius: 9999px | rounded-full |
| border-radius: 0 | rounded-none |
| width: 100% | w-full |
| width: 50% | w-1/2 |
| width: auto | w-auto |
| height: 100% | h-full |
| height: auto | h-auto |
| min-width: 0 | min-w-0 |
| min-height: 100vh | min-h-screen |
| position: relative | relative |
| position: absolute | absolute |
| position: fixed | fixed |
| position: sticky | sticky |
| overflow: hidden | overflow-hidden |
| overflow: auto | overflow-auto |
| overflow: scroll | overflow-scroll |
| overflow-x: auto | overflow-x-auto |
| opacity: 0 | opacity-0 |
| opacity: 0.5 | opacity-50 |
| opacity: 1 | opacity-100 |
| cursor: pointer | cursor-pointer |
| cursor: not-allowed | cursor-not-allowed |
| text-decoration: underline | underline |
| text-decoration: line-through | line-through |
| text-transform: uppercase | uppercase |
| text-transform: lowercase | lowercase |
| text-transform: capitalize | capitalize |
| gap: 4px | gap-1 |
| gap: 8px | gap-2 |
| gap: 16px | gap-4 |
| gap: 24px | gap-6 |
| box-shadow: 0 1px 2px rgba(0,0,0,0.05) | shadow-sm |
| box-shadow: 0 1px 3px rgba(0,0,0,0.1) | shadow |
| box-shadow: 0 4px 6px rgba(0,0,0,0.1) | shadow-md |
| box-shadow: 0 10px 15px rgba(0,0,0,0.1) | shadow-lg |
| transition: all 150ms | transition-all duration-150 |
| transition: all 300ms | transition-all duration-300 |