Lzh on GitHub

float

控制内容在元素周围环绕方式的工具类。

快速参考

类名样式
float-rightfloat: right;
float-leftfloat: left;
float-startfloat: inline-start;
float-endfloat: inline-end;
float-nonefloat: none;

示例

将元素浮动到右侧

使用 float-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.

<article>
  <img class="float-right ..." src="/img/mountains.jpg" />
  <p>也许我们可以没有图书馆,像你我这样的人。...</p>
</article>

将元素浮动到左侧

使用 float-left 工具类将元素浮动到其容器的左侧:

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.

<article>
  <img class="float-left ..." src="/img/mountains.jpg" />
  <p>也许我们可以没有图书馆,像你我这样的人。...</p>
</article>

使用逻辑属性

使用 float-startfloat-end 工具类,它们使用逻辑属性根据文本方向映射到左侧或右侧:

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

ربما يمكننا العيش بدون مكتبات، أشخاص مثلي ومثلك. ربما. بالتأكيد، نحن أكبر من أن نغير العالم، ولكن ماذا عن ذلك الطفل الذي يجلس ويفتح كتابًا الآن في أحد فروع المكتبة المحلية ويجد رسومات للتبول والبول على القطة في القبعة والإخوة الصينيون الخمسة؟ ألا يستحق الأفضل؟ ينظر. إذا كنت تعتقد أن الأمر يتعلق بالغرامات المتأخرة والكتب المفقودة، فمن الأفضل أن تفكر مرة أخرى. يتعلق الأمر بحق ذلك الطفل في قراءة كتاب دون أن يتشوه عقله! أو: ربما يثيرك هذا يا سينفيلد؛ ربما هذه هي الطريقة التي تحصل بها على ركلاتك. أنت ورفاقك الطيبين.

<article>
  <img class="float-start ..." src="/img/mountains.jpg" />
  <p>也许我们可以没有图书馆,像你我这样的人。...</p>
</article>
<article dir="rtl">
  <img class="float-start ..." src="/img/mountains.jpg" />
  <p>... ربما يمكننا العيش بدون مكتبات، أشخاص مثلي ومثلك. ربما. بالتأكيد</p>
</article>

禁用浮动

使用 float-none 工具类重置应用于元素的任何浮动:

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.

<article>
  <img class="float-none ..." src="/img/mountains.jpg" />
  <p>也许我们可以没有图书馆,像你我这样的人。...</p>
</article>

响应式设计

float 工具类添加断点变体的前缀(如 md:),以便仅在中等屏幕尺寸及以上应用该工具类:

<img class="float-right md:float-left" src="/img/mountains.jpg" />

变体文档 中了解更多关于使用变体的信息。