- Mastering CSS
- Rich Finelli
- 184字
- 2021-07-08 09:45:58
Using the clear method
Let's solve this using the clear property. What we'll do at the end of secondary-section is add a class of clear to a new div, using the following code:
<div class="clear"></div>
Next, we'll go into our CSS, and in the area reserved for global styles, underneath the ruleset targeting the wrapper class; this is where we'll create the clear selector and add clear: both:
/***************
Global
***************/
::-moz-selection {
background-color: #eb2428;
}
::selection {
background-color: #eb2428;
}
.wrapper {
margin: 0 auto;
width: 960px;
}
.clear {
clear: both;
}
So, if we save this and return to the browser, our background color will be green with a bottom margin of 50px. Everything is working very well:

However, we've added extra non-semantic markup to our page. We may even get an SEO deduction for this. Let's explore other ways to do this without adding the extra markup. Get rid of that extra markup we just added to our HTML:
<div class="clear"></div> <!-- delete this -->
Our collapse will return. Now we won't be able to see the green background anymore; that's how we know the collapse is there:

- Extending Jenkins
- .NET之美:.NET關鍵技術深入解析
- Python從菜鳥到高手(第2版)
- Reactive Programming with Swift
- Rust編程從入門到實戰
- BeagleBone Media Center
- Scratch 3.0少兒編程與邏輯思維訓練
- Learning Zurb Foundation
- 西門子S7-200 SMART PLC編程從入門到實踐
- UML2面向對象分析與設計(第2版)
- C語言程序設計與應用實驗指導書(第2版)
- Learning Shiny
- Java程序設計教程
- Responsive Web Design with jQuery
- Hadoop Blueprints