当前位置:网站首页>Float floating layout clear floating
Float floating layout clear floating
2022-06-21 09:17:00 【Tie Hanhan plus】
Let's take a look at the problematic floating layout :


You'll find that ul The following content will be crowded to the right , This is because the floating label has no height problem .
Next, let's talk about four ways to clear floats :
- Add... To the parent class that needs to clear the float overflow: hidden( But this will directly hide the contents of the overflow part of the sub tag )
- Clear floating mode 2 : Partition method , Add an empty tag below the one that needs to clear the float , Then add... To the empty tag clear: both attribute ( influence : Add extra meaningless labels , Poor readability and maintainability )
- Clear floating mode 3 ( Partition method upgraded ): Add... To the parent class that needs to clear the float after pseudo-classes , Also add the following styles ( There is no need to add additional labels )
- Clear floating mode 4 ( Double pseudo class clear floating ): Add... To the parent class that needs to clear the float clear-fix The class can
The following code is posted directly to show (vue Code ):
<template>
<!-- Remove the floating -->
<div class="clear-float-container">
<ul class="clear-fix">
<li> card 1</li>
<li> card 2</li>
<li> card 3</li>
<li> card 4</li>
<li> card 5</li>
<li> card 6</li>
</ul>
<!-- Clear floating mode 2 : Partition method , Add an empty tag below the one that needs to clear the float , Then add... To the empty tag clear: both attribute ( influence : Add extra meaningless labels , Poor readability and maintainability )-->
<!-- <div class="clear-float"></div>-->
<p> Need to clear float </p>
</div>
</template>
<script> export default {
name: 'CleanFloat', data () {
return {
} } } </script>
<style scoped lang="less"> // Clear floating mode 4 ( The double pseudo element clears the float ): Add... To the parent class that needs to clear the float clear-fix The class can ----start .clear-fix:before, .clear-fix:after {
content: ''; display: table; } .clear-fix:after {
clear: both; } .clear-fix {
*zoom: 1 // compatible ie } // Clear floating mode 4 ( The double pseudo element clears the float ): Add... To the parent class that needs to clear the float clear-fix The class can ----end .clear-float-container {
>ul {
list-style: none; width: 336px; margin: 0 auto; //overflow: hidden; // Clear floating mode one : Add... To the parent class that needs to clear the float overflow: hidden( But this will directly hide the contents of the overflow part of the sub tag ) li {
float: left; margin-right: 12px; margin-bottom: 12px; padding: 10px; width: 100px; background-color: #9a6e3a; } } .clear-both:after {
// Clear floating mode 3 ( Partition method upgraded ): Add... To the parent class that needs to clear the float after Pseudo elements , Also add the following styles ( There is no need to add additional labels ) content: ''; display: block; // You need to convert inline elements to block level elements clear: both; } .clear-float {
clear: both; } } </style>
边栏推荐
- Source insight shortcut key cross reference
- Topic34——31. Next spread
- Binary search (non recursive, no repeating elements)
- sql查看数据库/表磁盘占用情况,杀死进程终止tidb中的连接
- [practice] stm32mp157 development tutorial FreeRTOS system 6: FreeRTOS list and list items
- leetcode:19. 删除链表的倒数第 N 个结点
- Zhihu wanzan: what kind of programmers are still wanted by the company after the age of 35? Breaking the "middle age crisis" of programmers
- Reading method (three times reading method)
- The skill of using ADB and the principle of USB communication
- Thread pool source code analysis_ 01 futuretask source code analysis
猜你喜欢

Stm32mp1 cortex M4 development part 12: expansion board vibration motor control

应用配置管理,基础原理分析

The next stop of Intelligent Manufacturing: cloud native + edge computing two wheel drive

一条命令开启监控之旅!

Storage of floating point numbers in C language in memory

Alibaba P6 employees came to a small company for an interview and asked for an annual salary increase of 500000 yuan. How dare you speak

PingCAP 入选 2022 Gartner 云数据库“客户之声”,获评“卓越表现者”最高分
![[early knowledge of activities] list of recent activities of livevideostack](/img/8c/f8007931b1a5944f3a0a243a5afcc4.png)
[early knowledge of activities] list of recent activities of livevideostack
![[actual combat] STM32 FreeRTOS migration series tutorial 7: FreeRTOS event flag group](/img/1c/10add042271c11cd129ddfce66f719.jpg)
[actual combat] STM32 FreeRTOS migration series tutorial 7: FreeRTOS event flag group

Zhihu wanzan: what kind of programmers are still wanted by the company after the age of 35? Breaking the "middle age crisis" of programmers
随机推荐
Nodejs post request JSON type and form type
Storage of C language integer in memory
Token, cookie and session
[actual combat] STM32 FreeRTOS migration series tutorial 2: FreeRTOS mutually exclusive semaphores
Tidb and MySQL modify system variables / common statements (kill the process in process)
微信小程序
Merge sort of sorting
[Mgt] model Mgt for code interpretation
Stm32mp1 cortex M4 development part 10: expansion board nixie tube control
Stm32mp1 cortex M4 development part 13: external interrupt of expansion board key
stm32mp1 Cortex M4开发篇12:扩展板震动马达控制
基于Retrotfit2.1+Material Design+ijkplayer开发的一个APP
Leetcode: print the common part of two ordered linked lists
Introduction to list operation in C #
TiDB3.0- 4.0 内存控制/修改日志保存天数/最大索引长度
Retrofit extended reading
并发-条件变量
Full stack development
Base de données de sauvegarde DumpLiNg
Common basic functions of R language: call the data editor with edit function to manually customize and edit the data object without changing the content of the original data object, and call the data