官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 东莞市| 巢湖市| 福安市| 方山县| 兴安盟| 辽源市| 玉树县| 息烽县| 莲花县| 黔南| 大邑县| 上虞市| 神木县| 乐至县| 广昌县| 宁晋县| 兴仁县| 通榆县| 元朗区| 昌邑市| 蒙自县| 南汇区| 岗巴县| 峡江县| 日土县| 崇文区| 建平县| 陆丰市| 利辛县| 阳朔县| 九龙城区| 清水河县| 房山区| 吴忠市| 阿鲁科尔沁旗| 大兴区| 工布江达县| 香格里拉县| 富裕县| 横峰县| 巢湖市|