使用 HTML Attribute Folder 隱藏 Utility
TailwindCSS 一個常被詬病的地方就是 class
attribute 有冗長的 utility,導致 HTML 的可讀性不佳,透過 HTML Attribute Folder 可將所有 utility 加以隱藏,只留下 class
,當需要維護時再點擊 class
展開即可。
失くすものさえない今が強くなるチャンスよ
TailwindCSS 一個常被詬病的地方就是 class
attribute 有冗長的 utility,導致 HTML 的可讀性不佳,透過 HTML Attribute Folder 可將所有 utility 加以隱藏,只留下 class
,當需要維護時再點擊 class
展開即可。
TailwindCSS is great for JAMstack, but we have to integrate TailwindCSS with Hugo manually.
People have been talking about the best way to sort your utility classes in TailwindCSS projects for many years. TailwindCSS announced the official Prettier plugin to solve this problem.
We can use selection
modifier to style the selected text.
We often show a red *
to indicate a required field. This can be done by after
modifier.
With new before
and after
modifiers, we can create lots of fun effects to decorate the element.
It’s worth noting that you don’t really need ::before
and ::after
pseudo-elements for most things in TailwindCSS projects — it’s usually simpler to just use a real HTML element.
$refs
is just like document.getElementById
or docuement.querySeletor
to access the DOM element.
We can use after
modifier to add a pseudo element on the fly and apply utility.
We can use before
modifier to add a pseudo element on the fly and apply utility.
We can use first-letter
modifier to style the first letter of the paragraph.
hover
modifier styles the element when hovered, whereas group-hover
modifier style the child element when hovered.
We can use visited
modifier to style the element when visited.
We can use hover
modifier to style the element when hovered.
We can use active
modifier to style the element when clicked.
We can use even
modifier to style the even rows of the List.
We can use odd
modifier to style the odd rows of the List.
We can use last-of-type
modifier to style the last row of the List.
We can use first-of-type
modifier to style the first row of the List.
We can use last
modifier to style the last row of the List.
We can use first
modifier to style the first row of the List.
We can use first-line
modifier to style the first line of the paragraph.
We can use uppercase
to convert text to uppercase without JavaScript.
We can use lowercase
to convert text to lowercase without JavaScript.
We can use normal-case
to reset capitalization at different breakpoints.
We can use capitalize
to convert text to title-case without JavaScript.
Flexbox is a new layout for CSS 3. We can use a simple way for layout instead of inline-block
or float
.
We can use basis
to set the initial size of Flex items.
We can use w-max
to let the content decide the largest width of the box without wrapping.
We can use w-min
to let the content decide the smallest width of the box without overflowing.
Since inline-block
makes the width of the element shrink to fit the content, we can’t use inline-block mx-auto
to make the element horizontal center.
The content from API may be short like one or two words, or lengthy like more than one line. We want to adjust the text alignment of the content by CSS automatically.
w-auto
is width: auto
, and w-full
is width: 100%
. But it seems no difference in TailwindCSS?
We can use h-screen
to set the height of the element as viewport.
We can use w-screen
to set the width of the element as viewport.
If we don’t set width
of the element, the width is automatically adjusted by the viewport. We can apply min-w-fit
to ensure minimum width as content width.
If we don’t set width
of the element, the width is automatically adjusted by the viewport. We can apply min-w
to ensure a minimum width.
We can use the h
series utility to set the height of the element.
We can use the w
series utility to set the width of the element.
Block element uses w-auto
for width. It will occupy the full width of the parent element. We can use w-fit
to make width as the content width, then use m-auto
to adjust margin automatically for horizontal center.