如何到达CSS禅? [英] How to reach CSS zen?

查看:67
本文介绍了如何到达CSS禅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CSS看起来像一套技巧给我。每当我看到一些css技术,它看起来更像是技巧的技巧。当我写CSS,我经常需要适应html结构,我感觉很糟。

CSS looks like a set of tricks to me. Whenever I read about some css technique, it looks much more like tricks that techniques. When I write CSS, I often need to adapt the html structure and I feel bad.

你有些人有一些启发,享受CSS禅吗?

Did some of you had some enlightenment and enjoy CSS zen ? How did you reach CSS zen ?

推荐答案

首先,完全分开内容和表示,我的意思是 COMPLETELY so ... no more

First of all, separate content and presentation completely, and I mean COMPLETELY so... no more

<strong class="red">[...]</strong>

(很遗憾,我看得太多)和所有其他的东西。

(Sadly I see this too much) and all of that other stuff.

css类(和id的)应该描述内容,而不是定义样式。
例如,这是完全允许的:

css classes (and id's) should describe the content, not define the style. for example, this is perfectly allowed:

<div id="question">
  <p>[...]</p>
</div>
<div id="answers">
  <div class="answer">
    <p>[...]</p>
    <div class="comment"><p>[...]</p></div>
    <div class="comment"><p>[...]</p></div>
  </div>
  <div class="answer">
    <p>[...]</p>
  </div>
</div>

你有足够的标签类和id来做某事,

you have enough tags classes and id's to do something with, yet no diveritis or presentation logic inside it.

记住...最重要的是要达到CSS zen是非常好的HTML,而不会导致变化。

remember... the most important thing to reach CSS zen is extremely well-formed HTML without getting diveritis

另外,如果你读一个CSS技巧,它通常不是很优化。你给出的例子可能更一般化,最后使用正常的编码。但是,发现这个版本的人没有继续追求,因为他发现他需要什么。

Also, if you read about a CSS trick, it is usually not very optimised. The example you gave can probably be more generalized, and finally work with normal coding. However the person who found this version didn't pursue it any further, since he found what he needed.

最后一个注意事项是首先设计内容,包括以后的功能的HTML。

One last note is to design first for content, and include the HTML for features later on.

这篇关于如何到达CSS禅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆