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

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:

主站蜘蛛池模板: 茶陵县| 咸宁市| 南康市| 吉安市| 武强县| 庆阳市| 揭西县| 长沙县| 宜兰市| 内乡县| 聂荣县| 通化县| 绥化市| 柘城县| 康乐县| 呼和浩特市| 杭锦后旗| 远安县| 禄劝| 达拉特旗| 铜山县| 保康县| 开封市| 原阳县| 武功县| 嵩明县| 华池县| 禹州市| 池州市| 宜丰县| 丰城市| 泽州县| 新晃| 沧州市| 城步| 河源市| 颍上县| 偏关县| 龙陵县| 荣成市| 昭苏县|