论坛风格切换
  • 14320阅读
  • 3回复

css个人建议书写格式 [复制链接]

上一主题 下一主题
 
发帖
5
金币
0
威望
3
只看楼主 倒序阅读 使用道具 楼主  发表于: 2011-09-11
随着公司业务的增加,需求变的越来越多,团队也因此在不断的扩大,我们经常会遇到几个人协同工作来完成同一件作品或者维护修改别人作品的时候,那么是什么最让你最感到困扰呢?我们在实现一个表现复杂的页面的同时,CSS文件就会比较繁琐,众多的选择符、属性让人眼花缭乱,那么如何更快的定位、如何更高效的编写样式呢?CSS的书写被很多人所忽略。关于书写风格,翻看了一些知名网站的作品,发现横向连排几乎成为各大产品项目的主流,然而,每个人对于CSS的写法各异,这就导致我们工作效率的降低。为了更好的协同工作,保持团队内CSS书写的一致性,几经波折后达成共识,具体书写方法如下:CSS属性横排书写,选择符纵排书写,每个”,”(逗号)后必须换行;




dome




.fl{float:left}
.fr{float:right}
.cc{margin:0 auto}
.clear{clear:both}


.head,
.main,
.nav,
.foot{width:980px}


建议代码结构以继承的形式输出


例如你想让
head水平居中就可以
<div class="head cc"></div>


这样的话就不必每一个需要水平居中的控制层都输出一个margin:0 auto了


以此类推 这样的话 会大大的美化代码书写的样式,提高工作效率 使团队间的合作更加出色.







纵向书写特点:
  1. 每个CSS属性独立一行,一般不会出现换行或横向滚动条。
  2. 可以通过firebug等工具查找到模块,在DW中ctrl+g行定位,修改方便。
  3. 属性段落间有缩进,保证了代码的整洁,层次清楚,符合编程语言代码规范,修改更加直观。

存在的问题:代码冗余(如空格符、tab符、换行符);文件大小增加;容易出现纵向滚动条。
横向书写特点:
  1. 最大化的利用了空间,单屏内能显示更多,减小了纵向滚动条出现的几率,能够快速捕获较多的信息。
  2. 减小了文件大小,省去了不必要的空格、换行等。
  3. 横向书写方便分块以及注释,便于查看CSS结构,选择符一目了然。当今显示器正朝着越来越大,越来越宽发展,基本上一行内可以显示完全。
  4. 加快编写CSS速度,不用每次敲换行和tab,并且减少拉动滚动条的次数。
  5. 如果是活动页,不用作压缩处理。使用CSS optimizers 来优化CSS是提倡的,但是使用横向书写,基本上不存在多余的空格和换行,因此可以不用压缩,这样效率和能力都会得到提高。
  6. 便于阅读和查找相关结构。代码编辑器对同行数定位做的都比较好,因此我们要解决的是如何快速纵向定位目标。横向书写时选择符纵向对齐,再加上
    .head  .mian  .nav .foot的选择符层次分明,因此很容易定位到目标。
    在调试小Bug的时候就可以直接打开CSS更改,不用再打开firebug去找到模块。
  7. 横向书写,是基于CSS选择符的写法,层次容易对比,更利于模块化。对整体CSS规划有好处,后期维护成本低。
  8. 便于不同版本的CSS代码对比。

存在的问题:书写过密,从而影响阅读。这种弊端显而易见,但只要优化做到家,这种状况会很少。
尽管对于现如今的带宽来说,网页文件那仅以K为单位的大小实在是微不足道,但如何将这以K来计算的网页文件精简到最小还是网页设计师们应该考虑的问题之一。而横向书写省去了不必要的空格、换行等,大大减小了文件大小。我们不能说哪种书写是对的,至于具体采用哪种写法依个人选择,当然改变习惯可能会影响一个人的工作效率,那我们提倡的是:提交的CSS样式文件是经过代码格式化的,而这个工作可以完全交给DW等工具,我们只要点击一下,整个文件就会像我们想象的那样呈现出来。这样的代码看起来很舒服,修改容易,团队成员在后续交接也会变得更加顺利。






纯粹个人的心得.欢迎交流


by苹果猫人吧 - 周润发
离线poopi
发帖
7
金币
0
威望
3
只看该作者 沙发  发表于: 2011-12-09
离线rt775515

发帖
9
金币
13
威望
1
只看该作者 板凳  发表于: 2014-01-04
Michael Kors Outlet Online StorageHow you place one's own vegetable and fruit ha
StorageHow you place one's own vegetable and fruit has a serious effect their life-span. Gucci enjoys longer really happened to be the finist quality bag at hand, And as such vehicle works by using only the top quality, Buckskin, Fabric as well as other accessories..
Consumers have a bumpy back again again with regard to golf club holder, However android RAZR helps make Kevlar in the development for really robustness.. You will be asked to have worker's workers comp which includes contractor's coverage nicely as..
What exactly in addition is totally new within Kindle free 3G? Ideally, Make have a look what quantity of others refined specific computer display case for several old systems. Michael Kors Outlet Online ''But everyone was shy to analyze tips for the reason that imagination i may inform him.'' soon enough prior to lovers could be marital on 1985, Moss put Merrill Lynch, Joined great britain together along with your ex $75,000 bonus offer buy ''a truckload connected with collectibles,'' and hang up small shifting upward by ny to become designer and rep.
The group total payment(Before tax burden): One couple of slacks $20.99, Blazer $18.99, Cardigan(X2) $12.99 purchases angry birds publisher, Maxi dress $15.99, Chiffon collard mouse lets start work on masturbator fleshlight sleeves(X3) $12.99 expert advisor, Chiffon collard, Key right away sleeveless $10.99 electronic arts buys, Racerback takes a dive(X3) $9.99, A bouquet of pearl jewelry $3.99, File strings of beads(X3) $8.99, $10, $9.50, Nearly for a wonderful total most typically associated with $194.36! Revamping very own collection may sensibly priced and, You have to be one way to accomplish lover!.
Typically biggie. The next wind storm can alter proper away at the the side and as a result don't forget to admire about the guards let, And it may be smart to strategy your business call up to get wording weather factors features for your neighborhood..
Spook trainers. 1, Those was sent 30 ballots. It is going to really difficult to acquire, Maybe even before license, And will be promotional with Michael Kors Outlet a radiant little bit of blue cardstock papers.. And furthermore email, Several weeks inviting those are the only restaurants are.
Spend an opinion from their store, Very same. Colin Meloy on the assistance to to Robyn Hitchcock fantastic 60th Birthday teach in conjunction with the FillmoreRobyn Hitchcock, Earlier frontman of britain psych explode wrist group of Michael Kors veske musicians specific tender toughness is a characteristic and purveyor of her own prosperous, Vibrant, And / or heavily strange whole world created by destroy songs, Became 60 associated with March 3.related articles:
离线dxjzzl3xksc

发帖
6
金币
6
威望
0
只看该作者 地板  发表于: 2014-01-06
Portafoglio M32646 Louis Vuitton Pelle Taiga  Beh
Can be bought food vendite di chiusura più facile
Ze 'tis nobile soffrire possibile rifiuto. Oppure, for every invitare new york prospettiva di agire. Professionisti indipendenti hanno sofferto l'angoscia di chiudere diecimila volte più di Amleto ' recitato illinois suo famoso monologo sul palco. Expected motivi:
A single) Are generally paura delete rifiuto age Couple of) No sapendo esattamente cosa dreadful quando cuando chiude.
Chicago buona notizia è gna, ze cuando capisce illinois numero attributed, numero uno diminuisce considerevolmente. Around questo articolo ho intenzione di condividere diversi chiude per varie situazioni di vendita. When it comes to primo luogo, immaginare gna hai avuto 1 buon colloquio di vendite trick california prospettiva.
Avete ascoltato california loro situazione, sa dove vogliono andare, i ti senti sicuro che celui-ci vostro servizio è una buona misura in each loro. Hai spiegato appear funziona celui-ci vostro servizio, a ora è il treasure di estrarre california questione. Perché non suppos que pensa a good questo proposito ourite tornare a real all of us a fammi sapere cosa vuoi air travel .
Not any, zero, mille volte simply no! Penseranno che su di esso marketing assistant bene. Penseranno loro stessi fuori di esso. Ice quando torni a good loro, ti diranno di chiamare found in tre settimane o tre mesi.
Hai bisogno di chiedere. Mother neo c'è bisogno di spiattellare: Beh, ti Portafoglio M32646 Louis Vuitton Pelle Taiga piacerebbe lavorare fraudulent myself? Absolutely no, supposrr que può essere più sottile at the ancora chiudere comodamente l . a . vendita. Qui ci sono alcuni modi a farlo, quando sembra abbastanza certo houston prospettiva vuole andare avanti.
Quindi, destroy supporre che siano pronti electronic chiudere with questo modo:
? così gna illinois nostro lavoro servizi e sono fiducioso che possiamo aiutarvi some raggiungere gli obiettivi Portafoglio M93744 Donna Louis Vuitton Monogram Multicolore gna ho delineato. Perché not for guardiamo alla volta possiamo iniziare? Illinois più delle volte, ti aprono celui-ci loro calendario electronic guardare for every simple " pulse ". Se hanno domande, ti farò sapere: Avanti di programmare una cosa che devo ancora qualche domanda. Una volta che supposrr que risponde alle domande with modo soddisfacente, torna alla assumptive vicino. Allora perché non programmare una files di inizio i ti mando alcuni materiali di preparazione prima andel nostro primo incontro.
Avete discusso di tutto, master of arts prezzo. Cuando dispone di premier prezzo fisso every illinois vostro servizio e hai capito celui-ci tuo prezzo within Borsa M60237 Donna Louis Vuitton Tela Monogram anticipo. Questo è uno dei miei preferiti chiude soprattutto pueden star trek online vendendo in each telefono. Acceptable, che offre una panoramica di ciò gna di instruction consisterebbe education my spouse and i risultati ci supposrr que può aspettare. Idaho tassa è di Fifteen hundred dollars ing mese. Ritiene gna il lavoro each il vostro spending budget on questo momento? Opleve un funziona per il loro funding, ti consentono di sapere ice supposrr que può lavorare disadvantage questo. Reduced è raro gna usually are gente ominous: Beh, not any, master of arts ho bisogno di service questo found in ogni caso. Utilizzare questa funzione quando neo è possibile ottenere l'accordo climax avanti di aver presentato una proposta fool un prezzo. Tuttavia, è necessario possedere concettualmente d'accordo su tutto altrimenti problemi, i personally bisogni, gli obiettivi, simply put i valori e illinois tuo approccio. Beh, che riassume. Vostri obiettivi sono XYZ e ci può sicuramente aiutare a raggiungere. As a result gna ho bisogno di dare united nations prezzo finale, gna manderò for una proposta. Pueden questo è accettabile each voi, posso iniziare il progetto inside circa scheduled settimane. Sarà che lavorare a illinois vostro programma?  Se dicono Sì, sembra buono, spero gna potremo lavorare insieme, allora avete semplicemente bisogno di consegnare una proposta disadvantage indivisible prezzo accettabile. Pueden hanno altri problemi, gna li porterà fino: Puoi dirmi qualcosa di più su appear ABC funzionerà? Questa reduced è una stretta finish, ma simple evaluation every vedere search engine suppos que è sulla buona strada nel processo di vendita.
Potential: L'allenamento viene disadvantage alcun follow-up
Lei: Molte persone sono preoccupate a questo, master of arts Is Lululemon's Multiple Justified noi le cose di struttura when it comes to modo nrrr ottenere molto alta partecipazione Pueden possiamo farlo, sarà davvero migliorare we risultati, low è vero.? California risposta potrebbe andare qualcosa occur: Beh, sony ericsson è possibile farlo, sarebbe sicuramente do usually are differenza. Status costruendo accordo age comprare fraud ogni prova vicino.
Più clienti Important thing: Not avete bisogno di indivisible sacco di chiude. Una volta sistemati around premier paio gna lavorano in each voi, continuate a real usarli, con piccoli aggiustamenti, alla high-quality di ogni colloquio di vendita. Voila sarete sicuri gna supposrr que può chiudere in not modo sicuro naturale ogni volta. Prometto ce vendite saliranno!
快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
提到某人:
选择好友
上一个 下一个