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

Summary

Over the years, developers have had to frequently write code that duplicates all or part of a selector—a perfect example is styling lists or navigation items. It's a real pain to have to write so much extra code; instead we can use nesting principles to help remove some of this code. We've covered a number of techniques around nesting in PostCSS throughout this chapter, so let's take a moment to review what we've learned.

We kicked off with an introduction to nesting, to help bring us up to speed, before launching into using the postcss-nesting plugin to create nested styles within PostCSS. We then moved on to creating our nesting demo. We began with preparing a plain vanilla CSS version, before taking a look at converting to existing processors such as SASS.

Moving on, we then took a look at converting our code using the postcss-nesting plugin, before exploring some of the pitfalls that are associated with nesting, and some of the tips and tricks we can use to reduce CSS specificity, one of the key issues associated with nesting.

We then rounded out the chapter with a look at BEM, and how it can be used in PostCSS. We covered some of the basic principles of this methodology, before applying it to a simple example. We also learned why it won't always work for every instance; for those where it is suitable, we took a brief look at how we can set PostCSS to automatically lint our BEM code.

Phew, a real whistle stop tour there! Hang on to your hats though, as it won't stop: in our next chapter, we're going to take a look at writing media queries, and how PostCSS can help with compiling them into valid CSS.

主站蜘蛛池模板: 沭阳县| 栖霞市| 积石山| 大庆市| 武安市| 屯门区| 前郭尔| 博兴县| 左云县| 定南县| 大港区| 广汉市| 瓦房店市| 儋州市| 凌源市| 河池市| 土默特右旗| 柏乡县| 胶州市| 申扎县| 扎兰屯市| 江油市| 永靖县| 邢台县| 乌拉特前旗| 宁波市| 清丰县| 光泽县| 宣汉县| 永善县| 襄垣县| 佛教| 海城市| 漠河县| 滦平县| 稷山县| 怀安县| 新疆| 衡阳县| 黎川县| 普兰店市|