您可以在仓库 Github 上找到本文中的所有代码。
您可以在这里查看视觉效果:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Clear Float</title> <link rel="stylesheet" href="styles.css" /> </head> <body> <div> <pre class="brush:php;toolbar:false">.box { float: left; width: 100px; height: 100px; margin: 10px; background-color: lightgreen; } .container { border: 2px solid black; padding: 10px; } .clearfix::after { content: " "; display: block; height: 0; /* optional */ visibility: hidden; /* optional */ clear: both; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Overflow</title> <link rel="stylesheet" href="styles.css" /> </head> <body> <p> <pre class="brush:php;toolbar:false">.one-line-overflow { width: 40px; height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .multiple-lines-overflow { width: 40px; height: 20px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
以上是清除浮动和溢出的详细内容。更多信息请关注PHP中文网其他相关文章!