在我的工作站代碼的高級開發人員是這樣的:爲什麼這種css組織的方法更好?
table {border-collapse: collapse;border-spacing: 0;}
fieldset,img {border: 0;}
address,button,caption,cite,code,dfn,em,input,optgroup,option,select,strong,textarea,th,var {font:inherit;}
del,ins {text-decoration: none;}
li {list-style: none;}
caption,th {text-align: left;}
h1,h2,h3,h4,h5,h6 {font-size: 100%;font-weight: normal;}
q:before,q:after {content: '';}
abbr,acronym {border: 0;font-variant: normal;}
sup{vertical-align: baseline;}
sub{vertical-align: baseline;}
legend {color: #000;}
strong{font-weight:600;}
我編寫這樣同樣的事情(的我回顧了高級開發人員之前曾在同一的CSS代碼的不同部分/重寫我的代碼):
html {
background-color: #7e1d32;
font: 16px/22px arial, sans-serif;
}
#outer_container {
min-height: 598px;
width: 100%;
background: #D4D4D4 url('../images/top_bg.gif') repeat-x top left;
}
#inner_container {
min-height: 698px;
width: 100%;
background: #D4D4D4 url('../images/top_designed_bg.jpg') repeat-x top center;
}
/* top orange banner */
#top_orange_bar {
height: 47px;
width: 100%;
background: transparent url('../images/top_orange_bg.gif') repeat top left;
}
#top_orange_bar_content {
width: 1026px;
margin: 0 auto;
}
#top_orange_bar_content .left {
float: left;
width: 730px;
margin-left: 40px;
}
#top_orange_bar_content .left h4 {
text-transform: uppercase;
letter-spacing: 1px;
font: bold 14px/52px arial, sans-serif;
color: #7f1e32;
}
#top_orange_bar_content .right {
float: right;
width: 160px;
margin-right: 40px;
text-align: right;
}
#top_orange_bar_content .right a {
margin-top: 8px;
}
高級開發人員編寫css代碼的好處是什麼?
不要搞錯*高級*與* *較好。 – alex 2012-01-17 00:02:50
我會說你的代碼比老年人好。你的CSS只針對你真正想改變的元素。老年人可能會格式化不具有意義的元素。 – gorootde 2012-01-17 00:04:44
@alex - 真實,但不要以爲高級在這種情況下更糟,因爲沒有真正的性能理由來爭論或反對長/短版本。兩者都是有效的。如果他們習慣了冗長的形式,那麼短的一個往往會讓其他程序員感到煩惱。無論如何,在我工作的公司中,我們沒有人像書本一樣閱讀CSS。這一切都是通過搜索完成的,所以組織是相對無關緊要的。 – 2012-01-17 00:07:13