clear
用于控制内容如何环绕元素的工具类。
快速参考
| 类 | 属性 |
|---|---|
clear-left | clear: left; |
clear-right | clear: right; |
clear-both | clear: both; |
clear-start | clear: inline-start; |
clear-end | clear: inline-end; |
clear-none | clear: none; |
示例
清除左侧
使用 clear-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.
<!-- [!code classes:clear-left] -->
<article>
<img class="float-left ..." src="/img/snow-mountains.jpg" />
<img class="float-right ..." src="/img/green-mountains.jpg" />
<p class="clear-left ...">Maybe we can live without libraries...</p>
</article>清除右侧
使用 clear-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.
<!-- [!code classes:clear-right] -->
<article>
<img class="float-left ..." src="/img/green-mountains.jpg" />
<img class="float-right ..." src="/img/snow-mountains.jpg" />
<p class="clear-right ...">Maybe we can live without libraries...</p>
</article>全部清除
使用 clear-both 工具类将元素定位到所有先前浮动元素的下方:
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.
<!-- [!code classes:clear-both] -->
<article>
<img class="float-left ..." src="/img/snow-mountains.jpg" />
<img class="float-right ..." src="/img/green-mountains.jpg" />
<p class="clear-both ...">Maybe we can live without libraries...</p>
</article>使用逻辑属性
使用 clear-start 和 clear-end 工具类,它们采用逻辑属性,会根据文本方向映射到左侧或右侧:
ربما يمكننا العيش بدون مكتبات، أشخاص مثلي ومثلك. ربما. بالتأكيد، نحن أكبر من أن نغير العالم، ولكن ماذا عن ذلك الطفل الذي يجلس ويفتح كتابًا الآن في أحد فروع المكتبة المحلية ويجد رسومات للتبول والبول على القطة في القبعة والإخوة الصينيون الخمسة؟ ألا يستحق الأفضل؟ ينظر. إذا كنت تعتقد أن الأمر يتعلق بالغرامات المتأخرة والكتب المفقودة، فمن الأفضل أن تفكر مرة أخرى. يتعلق الأمر بحق ذلك الطفل في قراءة كتاب دون أن يتشوه عقله! أو: ربما يثيرك هذا يا سينفيلد؛ ربما هذه هي الطريقة التي تحصل بها على ركلاتك. أنت ورفاقك الطيبين.
<!-- [!code word:dir="rtl"] -->
<!-- [!code classes:clear-end] -->
<article dir="rtl">
<img class="float-left ..." src="/img/green-mountains.jpg" />
<img class="float-right ..." src="/img/green-mountains.jpg" />
<p class="clear-end ...">...ربما يمكننا العيش بدون مكتبات،</p>
</article>取消清除
使用 clear-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.
<!-- [!code classes:clear-none] -->
<article>
<img class="float-left ..." src="/img/green-mountains.jpg" />
<img class="float-right ..." src="/img/snow-mountains.jpg" />
<p class="clear-none ...">Maybe we can live without libraries...</p>
</article>响应式设计
使用 md: 等断点变体作为 clear 工具类的前缀,即可仅在中等及以上屏幕尺寸下应用该工具类:
<p class="clear-left md:clear-none ...">
Lorem ipsum dolor sit amet...
</p>了解如何使用变体,请参阅变体文档。