CSS---通向臃肿的道路(关于 “separation of concerns” (SoC)的原则)

  When it comes to CSS, I believe that the sacred principle of “separation of concerns” (SoC) has lead us to accept bloat, obsolescence, redundancy, poor caching and more. Now, I’m convinced that the only way to improve how we author style sheets is by moving away from this principle.

 

The Path To Bloat

Because the styles of our module are tied only to presentational class names, they can be anything we want them to be. For example, if we need to create a simple two-column layout, all we need to do is replace the link with a div in our template. That would look like this:

<div class="Bfc M-10">
    <div class="Fl-start Mend-10 W-25">
        column 1
    </div>
    <div class="Bfc">
        column 2
    </div>
</div>

And we would need only one extra rule in the style sheet:

.Bfc {
    overflow: hidden;
    zoom: 1;
}
.M-10 {
    margin: 10px;
}
.Fl-start {
    float: left;
}
.Mend-10 {
    margin-right: 10px;
}
.Fz-s {
    font-size: smaller;
}
.W-50 {
    width: 50%;
}

Compare this to the traditional way:

<div class="wrapper">
    <div class="sidebar">
        column 1
    </div>
    <div class="content">
        sidebar
    </div>
</div>

This would require us to create three new classes, to add an extra rule and to group selectors.

.wrapper,
.content,
.media,
.bd {
    overflow: hidden;
    _overflow: visible;
    zoom: 1;
}
.sidebar {
    width: 50%;
}
.sidebar,
.media .img {
    float: left;
    margin-right: 10px;
}
.media .img img {
    display: block;
}

I think the code above pretty well demonstrates the price we pay for following the SoC principle. In my experience, all it does is grow style sheets.

Moreover, the larger the files, the more complex the rules and selectors become. And then no one would dare edit the existing rules:

  • We leave alone rules that we suspect to be obsolete for fear of breaking something.
  • We create new rules, rather than modify existing ones, because we are not sure the latter is 100% safe.

In other words, we make things worse because we can get away with bloat.

Nowadays, people are accustomed to very large style sheets, and many authors think they come with the territory. Rather than fighting bloat, they use tools (i.e. preprocessors) to help them deal with it. Chris Eppstein tells us:

"LinkedIn has over 1,100 Sass files (230k lines of SCSS) and over 90 web developers writing Sass every day."    

转载于:https://www.cnblogs.com/JesseP/p/10248078.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 油水分离的前沿技术包括: 1. 超声波技术:通过高频声波在油水混合物中产生微小空泡,使油和水分离。 2. 动力学分离技术:通过油水混合物的物理性质,如密度、流动性等差异,将油和水分离。 3. 光学分离技术:利用油和水在光学特性上的差异,如光吸收、折射率等,将油和水分离。 4. 膜技术:通过膜的选择性透过性,将油和水分离。 5. 化学吸附技术:通过合适的化学吸附剂,吸附油,使油和水分离。 这些技术具有不同的优缺点,根据实际应用情况,应选择合适的技术。 ### 回答2: 油水分离的前沿技术是指在处理含油废水时使用的最新科技和方法。由于油污水的治理一直是一个全球性的环境问题,因此研究人员一直在努力开发更有效的方法来分离油水,以减少对环境的污染。 一种前沿技术是利用纳米材料进行油水分离。纳米材料具有大比表面积和特殊的化学和物理性质,可以吸附或分解油污染物。这种技术通过将纳米材料应用于分离设备中,可以高效地分离油水混合物。纳米材料的使用还可以提高设备的储油容量和改善处理效率。 另一种前沿技术是利用膜分离技术进行油水分离。膜分离技术利用特殊的膜材料将油和水分离开来。这种技术相对传统的方法具有更高的分离效率和选择性。同时,膜分离技术还可以实现连续操作和减少处理成本。 此外,一种新兴的技术是利用电化学方法进行油水分离。该方法通过电场效应使油和水分离开来。这种技术具有高效、环保和可控性的优势,可以有效地处理不同种类的油污染物。 总之,油水分离的前沿技术为解决油污染问题提供了新的方法和可能性。这些技术在提高分离效率、降低处理成本和减少环境污染方面具有重要意义,对于推动可持续发展和保护环境具有重要作用。 ### 回答3: 油水分离的前沿技术是一种用于将油和水分离的先进技术。油水分离是一项重要的环境工程技术,用于处理由油污染引起的水体和废水。过去,常用的油水分离方法包括重力分离、漂浮、离心分离等,但这些方法存在一些局限性。 随着科技的进步,油水分离的前沿技术不断涌现。一个前沿技术是电化学油水分离法。该技术利用电解作用将水中的油脂离子化,然后利用电极的特殊性质将油脂吸附并分离出来。这种方法具有高效、节能、环保等优点,可以有效地从废水中分离出油脂。 另一个前沿技术是膜分离技术。膜分离技术利用特殊的薄膜材料,如聚合物膜、陶瓷膜等,通过渗透、过滤和离子交换等机制实现油水分离。这种技术具有高效、节能、可持续等特点,可以有效地去除水中的油污染物。 此外,纳米技术也被应用于油水分离的前沿技术中。纳米材料具有巨大的比表面积和特殊的物理化学性质,可以用于油水分离膜、吸附材料等的制备。通过纳米材料的使用,油水分离的效率和效果能够得到显著提高。 总之,油水分离的前沿技术不断涌现,为处理油污染带来了新的可能性。电化学油水分离、膜分离技术和纳米技术等都是重要的前沿技术,将为环境保护和资源开发提供有力支持。随着科学技术的发展,我们可以期待更多创新的油水分离技术的出现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值