DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS進階教程
CSS 代碼優化的兩個理由:讓檔案更小、代碼更乾淨
編輯:CSS進階教程     

為什麼要進行 CSS 代碼優化?

主要有兩個原因。其一,它能幫你把 CSS 檔案縮得更小;其二,它能讓你寫出更乾淨的代碼。這套優化工具讓你可以自行決定壓縮的程度——從幾乎無法被人類閱讀編輯的「超壓縮」,到兼顧視覺舒適的排版,任你拿捏。我偏好標準設定,因為它能同時兼顧檔案大小與可讀性。

另一個很實用的特色,是它能協助你使用速記寫法。我絕非 CSS 專家,尚未把各種速記法背得滾瓜爛熟。如果你和我一樣用 Dreamweaver,會發現它喜歡把每條規則各自獨立成行——這種冗長寫法在複製貼上、做點小修改時特別枯燥。其實很多屬性都能濃縮成一條,例如 background 與 border。所以,優化的主要目的,就是確保你的 CSS 檔案保持乾淨。乾淨而精煉的代碼本身就是一種藝術,即使我不是工程師,也能看得出它的美感。身為一名設計者,這個工具確實幫我大幅提升了效率。

Why CSS optimize?

Well for two reasons mainly. It helps you get smaller CSS file sizes and better written code. The way the optimizer works actually lets you decide how much compression you want. From super compressed (virtually unreadable and editable by a human being) to visually pleasing. I prefer the standard setting because it gives you a little of both.

Another cool feature is that it helps you with shorthand coding. I am by no means an expert at CSS. I do not have all the shorthand methods memorized (yet!). For those of you using Dreamweaver, like myself, you'll find that it likes to use longhand code. By this I mean putting each seperate rule on it's own line. This can get tedious copying and pasting it make a small change. A lot of that stuff can get consolidated into one line, like backgrounds and borders.

So your main reasons for wanting to optimize are to make sure your CSS files are clean. There is a certain art form in clean and concise code. And I'm not even a programmer and I can see that. I'm an artist, so this tool really helps speed things up.

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved