Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)
published in(发表于) 2016/5/7 5:51:42
10 CSS development “do not“,

English

中文

10 CSS development "not"-CSS, programming-IT information

Self in this business, I found that developers have been trying to conquer the CSS.

Reason is sufficient, developers think in logic creature. Add a DIV element leads to all the code has to move down one line, while another DIV "float" to the left, I feel doesn't make any sense.

You must have heard developers complain about:

"We just need to move the five pixels to the left, but ... Oh, my God! Why are moved down the row as a whole. Where the hell is wrong?!?!?! ”

So, today we will talk about ten errors in the CSS approach.

According to my experience as a developer using CSS, here are my ten "no".

1. do not abuse the class

Meaningful use ID instead of a class. This is a method that enables browsers to access DOM elements faster.

2. do not throw everything into a CSS file

Partition CSS makes it easier to manage. Each CSS file can be broken down into for example header.CSS, footer.CSS and other logical components.

3. don't name selector to ". red-with-green-dashed-lines" (red and green dashed line)

Named according to the component on the page of your choice. For example: "header-left", "content-title" or "content-date" is more descriptive.

4. don't forget to comment

Comments in CSS is very important, to understand how each style and other styles available associate and what color scheme applies to which components.

5. don't be afraid to development tools

Now, each browser has its own set of development tools, usually by pressing F12. These tools are the "Debugging CSS" is crucial.

6. don't be afraid to cover

Of course, CSS frameworks, such as Bootstrap and Foundation is great, but each needs to make adjustments according to your needs. When you get an update of the framework, it will overwrite your changes. Instead of digging a large CSS file, it is better to create a bootstrap-overrides.CSS file, you will resize the frame, just ...

7. do not abuse! Very important

The whole idea of CSS is, from one to another, "cascading" style.! key to keep in mind like mine to step through all the previous style. :?-)

8. do not use a lot of Web fonts

This is obvious, but some people just like their layout. Only use one or two on the site (up to three) network fonts, then back to the browser default settings to keep the website optimization.

9. don't hand-code all the CSS

In keeping with CSS DRY, you can use CSS pre-processor like SASS or LESS. Using the preprocessor's biggest advantage is that you can define a variable, for example in the color scheme defined above, then repeat using all CSS, instead of when you need to modify the track each color.

10. don't let the CSS too "bloated"

Space space space takes up the CSS file. Because we want our CSS to load quickly, so before deployment to the Web site better to use CSS compress tools to a thin body.

Just above me, as a developer in the preparation of the CSS should not do things. Welcome to put forward different views.


CSS开发中的10个“不要” - CSS,编程 - IT资讯

自我进入这个行业,我就发现开发人员一直在努力征服CSS。

理由也很充分,开发人员是用逻辑思考的生物。添加一个DIV元素导致所有代码都不得不往下移一行,而另一个DIV“浮”到左侧,感觉没有任何意义。

你也一定听到过开发人员的抱怨:

“我们只需要向左边移动五个像素,但是…天哪!为什么整个都向下移动了一行。到底是哪里错了?!?!?!”

所以,我们今天就来聊一聊CSS中的十大错误的做法。

根据我作为开发人员使用CSS的经验,下面是我的十个“不要”。

1.不要滥用类

在有意义的地方使用ID而不要使用类。这是一个使得浏览器能够更快访问DOM元素的方法。

2.不要把一切都扔进一个CSS文件中

分区CSS使其更易于管理。每一个CSS文件都可以分解成例如header.css、footer.css等逻辑组件。

3.不要命名选择器为“.red-with-green-dashed-lines”(红绿虚线)

根据页面上的组件命名你的选择器。例如:“header-left”,“content-title”或“content-date”更具描述性。

4.不要忘记注释

注释在CSS中非常重要,可用来理解每个样式如何与其他样式关联以及什么颜色方案适用于哪些组件。

5.不要害怕开发工具

现在的每个浏览器都有自己的一套开发工具,通常是按F12。这些工具在“调试CSS”时至关重要。

6.不要害怕覆盖

当然,CSS框架,例如Bootstrap和Foundation都较为巨大,但每一个都需要根据你的需要做出一点调整。当你得到一个更新的框架时,它将覆盖你的改变。与其深入挖掘庞大的CSS文件,还不如创建一个bootstrap-overrides.css文件,按照你的意愿调整框架,只是…

7.不要滥用! 很重要

CSS的整体思路是,从一个到另一个地“层叠”样式。!重点是要记住排雷一样地踏遍所有早先的样式。: -)

8.不要使用大量网络字体

这也是显而易见的,但有些人就是喜欢自己排版。只在网站上使用一个或两个(最多三个)网络字体,然后回归到浏览器默认设置,以保持网站的优化。

9.不要手动编码所有的CSS

为了保持CSS的DRY,可以使用CSS预处理程序例如LESS或SASS。使用这些预处理器的最大好处是,你可以定义变量,例如在上面定义配色方案,然后重复使用到所有CSS,而不必当你需要修改的时候追踪每个颜色。

10.不要让CSS过于“臃肿”

空格会占用CSS文件的空间空间。由于我们都希望我们的CSS能够快速加载,因此在部署到网站之前最好使用CSS压缩工具来一次瘦身。

以上只是我作为一个开发人员在编写CSS时认为不应该做的事情。欢迎提出不同的看法。






If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759