布局
用于控制元素周围内容封装的工具。
¥Basic usage
¥Floating elements to the right
使用 float-right
工具将元素浮动到其容器的右侧。
¥Use the float-right
utility to float an element to the right of its container.
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld; maybe that's how y'get your kicks. You and your good-time buddies.
<img class="float-right ..." src="path/to/image.jpg">
<p>Maybe we can live without libraries, people like you and me. ...</p>
¥Floating elements to the left
使用 float-left
工具将元素浮动到其容器的左侧。
¥Use the float-left
utility to float an element to the left of its container.
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld; maybe that's how y'get your kicks. You and your good-time buddies.
<img class="float-left ..." src="path/to/image.jpg">
<p>Maybe we can live without libraries, people like you and me. ...</p>
¥Disabling a float
使用 float-none
工具重置应用于元素的任何浮动。这是 float 属性的默认值。
¥Use the float-none
utility to reset any floats that are applied to an element. This is the default value for the float property.
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld; maybe that's how y'get your kicks. You and your good-time buddies.
<img class="float-none ..." src="path/to/image.jpg">
<p>Maybe we can live without libraries, people like you and me. ...</p>
¥Using logical properties
使用 float-start
或 float-end
工具,它们使用 逻辑属性 根据文本方向映射到左侧或右侧。
¥Use the float-start
or float-end
utilities, which use logical properties to map to either the left or right side based on the text direction.
left-to-right
Maybe we can live without libraries, people like you and me. Maybe. Sure, we're too old to change the world, but what about that kid, sitting down, opening a book, right now, in a branch at the local library and finding drawings of pee-pees and wee-wees on the Cat in the Hat and the Five Chinese Brothers? Doesn't HE deserve better? Look. If you think this is about overdue fines and missing books, you'd better think again. This is about that kid's right to read a book without getting his mind warped! Or: maybe that turns you on, Seinfeld; maybe that's how y'get your kicks. You and your good-time buddies.
right-to-left
ربما يمكننا العيش بدون مكتبات، أشخاص مثلي ومثلك. ربما. بالتأكيد، نحن أكبر من أن نغير العالم، ولكن ماذا عن ذلك الطفل الذي يجلس ويفتح كتابًا الآن في أحد فروع المكتبة المحلية ويجد رسومات للتبول والبول على القطة في القبعة والإخوة الصينيون الخمسة؟ ألا يستحق الأفضل؟ ينظر. إذا كنت تعتقد أن الأمر يتعلق بالغرامات المتأخرة والكتب المفقودة، فمن الأفضل أن تفكر مرة أخرى. يتعلق الأمر بحق ذلك الطفل في قراءة كتاب دون أن يتشوه عقله! أو: ربما يثيرك هذا يا سينفيلد؛ ربما هذه هي الطريقة التي تحصل بها على ركلاتك. أنت ورفاقك الطيبين.
<img class="float-start ..." src="path/to/image.jpg">
<p>Maybe we can live without libraries, people like you and me. ...</p>
<img class="float-start ..." src="path/to/image.jpg">
<p dir="rtl">... ربما يمكننا العيش بدون مكتبات، أشخاص مثلي ومثلك. ربما. بالتأكيد </p>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:float-right
to only apply the float-right
utility on hover.
<img class="float-right hover:float-left" src="path/to/image.jpg">
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:float-right
to apply the float-right
utility at only medium screen sizes and above.
<img class="float-right md:float-left" src="path/to/image.jpg">
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.