存儲非常特定於單個dom元素的樣式的首選方法是什麼?在一個單獨的CSS文件中,或在HTML文件中的樣式屬性內聯?Css最佳實踐:特定於單個dom元素的樣式
我給你舉個例子。這是我目前在一個CSS文件中的CSS。標題欄,產品標題,產品說明和類別圖像都是需要非常具體的樣式的元素,我絕不會在其他地方重複使用樣式。我非常想嘗試將它們添加到內聯中,並且只會在CSS文件中留下更一般的樣式。我應該這樣做嗎?爲什麼/爲什麼不?
#titlebar {
position: absolute;
top: 141px;
left: 80px;
width: 180px;
height: 38px;
line-height: 38px;
font-size: 18px;
font-weight: bold;
text-align: center;
color: white;
text-shadow: 0 -1px 0 #666;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#product-title {
position: absolute;
top: 190px;
left: 110px;
width: 190px;
height: 18px;
line-height: 18px;
font-size: 16px;
font-family: 'Droid Serif', Georgia;
color: black;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#product-description {
position: absolute;
top: 210px;
left: 110px;
width: 190px;
font-size: 10px;
height: 50px;
overflow: hidden;
text-overflow: ellipsis;
}
#category-image {
position: absolute;
top: 186px;
left: 43px;
width: 52px;
height: 60px;
}
緩存是一個很好的論點。 – Godisemo 2012-02-08 21:40:18